popularable 1.2.2 → 1.3.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 -1
- 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: e34ddd97dbe7f7ab647b5a69dd87c17716257d91
|
4
|
+
data.tar.gz: 199f8adc7b1e0b6c064f57e59ad94c4d7e22e590
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6773f828848ce71c568983373c285697ae2f131982140b709f5ad7bb69269d10b2af2b9e546eee5d76735953b9bfc41cf92b0c0c384a17e0b1cf8a6a9a57dc3
|
7
|
+
data.tar.gz: 9021be4556e8bacc2bf8b53d66fa1457387b5093661507740d76561fe6196e1a677f4d0df69c26212232cd46cddb76b670a94a48d65f8320b003334a54a55a41
|
data/lib/concerns/popularable.rb
CHANGED
@@ -22,7 +22,8 @@ module Popularable
|
|
22
22
|
}
|
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.to_s}')").group( "#{self.table_name}.id" ).order( "popularity DESC" )
|
26
27
|
}
|
27
28
|
|
28
29
|
scope :popular_since, -> (since){
|
data/lib/popularable/version.rb
CHANGED