recommendable 1.1.4 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.markdown +15 -1
- data/Gemfile.lock +2 -2
- data/app/models/recommendable/dislike.rb +4 -1
- data/app/models/recommendable/ignore.rb +4 -1
- data/app/models/recommendable/like.rb +5 -2
- data/app/models/recommendable/stash.rb +4 -1
- data/lib/recommendable/acts_as_recommendable.rb +19 -18
- data/lib/recommendable/version.rb +1 -1
- metadata +2 -2
data/CHANGELOG.markdown
CHANGED
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
Changelog
|
|
2
2
|
=========
|
|
3
3
|
|
|
4
|
-
1.1.
|
|
4
|
+
1.1.5 (Current version)
|
|
5
5
|
-----------------------
|
|
6
|
+
* Fix #47, a problem where models could not recommend themselves
|
|
7
|
+
|
|
8
|
+
1.1.4
|
|
9
|
+
-----
|
|
10
|
+
* Fix #41, a problem where Resque rake tasks were required regardless of whether or not it was bundled
|
|
11
|
+
* Fix #46 by adding UniqueJob middleware for Sidekiq.
|
|
12
|
+
* Added caches for an item's number of likes and dislikes received
|
|
13
|
+
|
|
14
|
+
1.1.3
|
|
15
|
+
-----
|
|
16
|
+
* Update Redis.
|
|
17
|
+
|
|
18
|
+
1.1.2
|
|
19
|
+
-----
|
|
6
20
|
* Fix #38, a problem with enqueueing users based on updating the score of a recommendable record
|
|
7
21
|
|
|
8
22
|
1.1.1
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
recommendable (1.1.
|
|
4
|
+
recommendable (1.1.5)
|
|
5
5
|
hooks
|
|
6
6
|
rails (>= 3.0.0)
|
|
7
7
|
redis (>= 2.2.0)
|
|
@@ -43,7 +43,7 @@ GEM
|
|
|
43
43
|
hooks (0.2.0)
|
|
44
44
|
i18n (0.6.0)
|
|
45
45
|
journey (1.0.4)
|
|
46
|
-
json (1.7.
|
|
46
|
+
json (1.7.4)
|
|
47
47
|
mail (2.4.4)
|
|
48
48
|
i18n (>= 0.4.0)
|
|
49
49
|
mime-types (~> 1.16)
|
|
@@ -7,7 +7,10 @@ module Recommendable
|
|
|
7
7
|
belongs_to :dislikeable, :polymorphic => true
|
|
8
8
|
|
|
9
9
|
validates :user_id, :uniqueness => { :scope => [:dislikeable_id, :dislikeable_type],
|
|
10
|
-
:message => "has already disliked this item" }
|
|
10
|
+
:message => "has already disliked this item" },
|
|
11
|
+
:presence => true
|
|
12
|
+
validates_presence_of :dislikeable_id
|
|
13
|
+
validates_presence_of :dislikeable_type
|
|
11
14
|
|
|
12
15
|
def dislikeable_type=(sType)
|
|
13
16
|
super sType.to_s.classify.constantize.base_class.to_s
|
|
@@ -7,7 +7,10 @@ module Recommendable
|
|
|
7
7
|
belongs_to :ignorable, :polymorphic => true
|
|
8
8
|
|
|
9
9
|
validates :user_id, :uniqueness => { :scope => [:ignorable_id, :ignorable_type],
|
|
10
|
-
:message => "has already ignored this item" }
|
|
10
|
+
:message => "has already ignored this item" },
|
|
11
|
+
:presence => true
|
|
12
|
+
validates_presence_of :ignorable_id
|
|
13
|
+
validates_presence_of :ignorable_type
|
|
11
14
|
|
|
12
15
|
def ignorable_type=(sType)
|
|
13
16
|
super sType.to_s.classify.constantize.base_class.to_s
|
|
@@ -4,10 +4,13 @@ module Recommendable
|
|
|
4
4
|
attr_accessible :user_id, :likeable_id, :likeable_type
|
|
5
5
|
|
|
6
6
|
belongs_to :user, :class_name => Recommendable.user_class.to_s, :foreign_key => :user_id
|
|
7
|
-
belongs_to :likeable, :polymorphic => true
|
|
7
|
+
belongs_to :likeable, :polymorphic => true, :foreign_key => :likeable_id
|
|
8
8
|
|
|
9
9
|
validates :user_id, :uniqueness => { :scope => [:likeable_id, :likeable_type],
|
|
10
|
-
:message => "has already liked this item" }
|
|
10
|
+
:message => "has already liked this item" },
|
|
11
|
+
:presence => true
|
|
12
|
+
validates_presence_of :likeable_id
|
|
13
|
+
validates_presence_of :likeable_type
|
|
11
14
|
|
|
12
15
|
def likeable_type=(sType)
|
|
13
16
|
super sType.to_s.classify.constantize.base_class.to_s
|
|
@@ -7,7 +7,10 @@ module Recommendable
|
|
|
7
7
|
belongs_to :stashable, :polymorphic => :true
|
|
8
8
|
|
|
9
9
|
validates :user_id, :uniqueness => { :scope => [:stashable_id, :stashable_type],
|
|
10
|
-
:message => "has already stashed this item" }
|
|
10
|
+
:message => "has already stashed this item" },
|
|
11
|
+
:presence => true
|
|
12
|
+
validates_presence_of :stashable_id
|
|
13
|
+
validates_presence_of :stashable_type
|
|
11
14
|
|
|
12
15
|
def stashable_type=(sType)
|
|
13
16
|
super sType.to_s.classify.constantize.base_class.to_s
|
|
@@ -7,19 +7,19 @@ module Recommendable
|
|
|
7
7
|
class_eval do
|
|
8
8
|
Recommendable.recommendable_classes << self
|
|
9
9
|
|
|
10
|
-
has_many :
|
|
11
|
-
|
|
12
|
-
has_many :
|
|
13
|
-
|
|
14
|
-
has_many :
|
|
15
|
-
|
|
16
|
-
has_many :
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
has_many :liked_by, :through => :
|
|
20
|
-
:class_name => Recommendable.user_class.to_s
|
|
21
|
-
has_many :disliked_by, :through => :
|
|
22
|
-
|
|
10
|
+
has_many :recommendable_likes, :as => :likeable, :dependent => :destroy,
|
|
11
|
+
:class_name => "Recommendable::Like"
|
|
12
|
+
has_many :recommendable_dislikes, :as => :dislikeable, :dependent => :destroy,
|
|
13
|
+
:class_name => "Recommendable::Dislike"
|
|
14
|
+
has_many :recommendable_ignores, :as => :ignorable, :dependent => :destroy,
|
|
15
|
+
:class_name => "Recommendable::Ignore"
|
|
16
|
+
has_many :recommendable_stashes, :as => :stashable, :dependent => :destroy,
|
|
17
|
+
:class_name => "Recommendable::Stash"
|
|
18
|
+
|
|
19
|
+
has_many :liked_by, :through => :recommendable_likes, :source => :user,
|
|
20
|
+
:foreign_key => :user_id, :class_name => Recommendable.user_class.to_s
|
|
21
|
+
has_many :disliked_by, :through => :recommendable_dislikes, :source => :user,
|
|
22
|
+
:foreign_key => :user_id, :class_name => Recommendable.user_class.to_s
|
|
23
23
|
|
|
24
24
|
include LikeableMethods
|
|
25
25
|
include DislikeableMethods
|
|
@@ -29,7 +29,7 @@ module Recommendable
|
|
|
29
29
|
def self.acts_as_recommendable?() true end
|
|
30
30
|
|
|
31
31
|
def been_rated?
|
|
32
|
-
|
|
32
|
+
recommendable_likes.count + recommendable_dislikes.count > 0
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
# Returns an array of users that have liked or disliked this item.
|
|
@@ -53,9 +53,9 @@ module Recommendable
|
|
|
53
53
|
return 0 unless been_rated?
|
|
54
54
|
|
|
55
55
|
z = 1.96
|
|
56
|
-
n =
|
|
56
|
+
n = recommendable_likes.count + recommendable_dislikes.count
|
|
57
57
|
|
|
58
|
-
phat =
|
|
58
|
+
phat = recommendable_likes.count / n.to_f
|
|
59
59
|
score = (phat + z*z/(2*n) - z * Math.sqrt((phat*(1-phat)+z*z/(4*n))/n))/(1+z*z/n)
|
|
60
60
|
|
|
61
61
|
Recommendable.redis.zadd self.class.score_set, score, self.id
|
|
@@ -93,14 +93,15 @@ module Recommendable
|
|
|
93
93
|
# @return [Array] an array of user IDs
|
|
94
94
|
# @private
|
|
95
95
|
def rates_by
|
|
96
|
-
|
|
96
|
+
recommendable_likes.map(&:user_id) + recommendable_dislikes.map(&:user_id)
|
|
97
97
|
end
|
|
98
98
|
|
|
99
99
|
def self.score_set
|
|
100
100
|
"#{self}:sorted"
|
|
101
101
|
end
|
|
102
102
|
|
|
103
|
-
private :
|
|
103
|
+
private :recommendable_likes, :recommendable_dislikes,
|
|
104
|
+
:recommendable_ignores, :recommendable_stashes
|
|
104
105
|
end
|
|
105
106
|
end
|
|
106
107
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: recommendable
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1.
|
|
4
|
+
version: 1.1.5
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2012-07-
|
|
12
|
+
date: 2012-07-30 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: sqlite3
|