popularable 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/concerns/popularable.rb +2 -2
- data/lib/popularable/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5dea7513ce34d50d024fa8a6bb339d282715b333
|
4
|
+
data.tar.gz: d68e83c7e24abb30727c69f06799371c69c63c0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3651f556ae0029a82fdffe76805dfbc206f711a84c06cdfd0e48ea83865cd0a50dff0499d7b8c98ba462dc282119ffedce9be05ac5051266786209c5c5ac51e
|
7
|
+
data.tar.gz: 8b110c87827bf75e8e7c1be428daa7184212091c88e6a76e4b1104ad7788adad3b709f0465a7439d995a7cbc0cd9897c40d9f10dbbad5eece529f54c87bead46
|
data/lib/concerns/popularable.rb
CHANGED
@@ -23,11 +23,11 @@ module Popularable
|
|
23
23
|
|
24
24
|
scope :popular_all_time, -> {
|
25
25
|
# This uses an inner join and ditches the unnecessary where clause for performance.
|
26
|
-
select( "#{self.table_name}.*, 0 + SUM(popularable_popularity_events.popularity) AS popularity").joins( "INNER JOIN popularable_popularity_events ON (#{self.table_name}.id = popularable_popularity_events.popularable_id AND popularable_popularity_events.popularable_type = '#{self.
|
26
|
+
select( "#{self.table_name}.*, 0 + SUM(popularable_popularity_events.popularity) AS popularity").joins( "INNER JOIN popularable_popularity_events ON (#{self.table_name}.id = popularable_popularity_events.popularable_id AND popularable_popularity_events.popularable_type = '#{self.name}')").group( "#{self.table_name}.id" ).order( "popularity DESC" )
|
27
27
|
}
|
28
28
|
|
29
29
|
scope :popular_since, -> (since){
|
30
|
-
select( "#{self.table_name}.*, 0 + SUM(popularable_popularity_events.popularity) AS popularity").joins( "LEFT OUTER JOIN popularable_popularity_events ON (#{self.table_name}.id = popularable_popularity_events.popularable_id AND popularable_popularity_events.popularable_type = '#{self.
|
30
|
+
select( "#{self.table_name}.*, 0 + SUM(popularable_popularity_events.popularity) AS popularity").joins( "LEFT OUTER JOIN popularable_popularity_events ON (#{self.table_name}.id = popularable_popularity_events.popularable_id AND popularable_popularity_events.popularable_type = '#{self.name}')").where( "popularable_popularity_events.popularity_event_date >= ?", since.to_date ).group( "#{self.table_name}.id" ).order( "popularity DESC" )
|
31
31
|
}
|
32
32
|
|
33
33
|
has_many :popularable_popularity_events, as: :popularable
|
data/lib/popularable/version.rb
CHANGED