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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d0745f50702b80911d1948e8b772f8790c5980c0
4
- data.tar.gz: 09e203c343e1c476638c693d04ace162e4ef9d4e
3
+ metadata.gz: e34ddd97dbe7f7ab647b5a69dd87c17716257d91
4
+ data.tar.gz: 199f8adc7b1e0b6c064f57e59ad94c4d7e22e590
5
5
  SHA512:
6
- metadata.gz: 5cb6bf92cb6139812a881f0a208017af720aa3a2736bd3981653fc2a32542d5d8482fbc493e7fac1b1607d5a99a5299a7aff9573079e522b721b76e6000e753e
7
- data.tar.gz: dbd8b69f52684cd24fd3a048e5c3a989f2dc42a9d5d23365ab613e2700110b290ee1476e2f4fe849da2b05a0f4b3fc23ca3bb95c077a09ea1c6702fb27bf5905
6
+ metadata.gz: d6773f828848ce71c568983373c285697ae2f131982140b709f5ad7bb69269d10b2af2b9e546eee5d76735953b9bfc41cf92b0c0c384a17e0b1cf8a6a9a57dc3
7
+ data.tar.gz: 9021be4556e8bacc2bf8b53d66fa1457387b5093661507740d76561fe6196e1a677f4d0df69c26212232cd46cddb76b670a94a48d65f8320b003334a54a55a41
@@ -22,7 +22,8 @@ module Popularable
22
22
  }
23
23
 
24
24
  scope :popular_all_time, -> {
25
- popular_since( Time.now - 100.years )
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){
@@ -1,5 +1,5 @@
1
1
  module Popularable
2
2
  module Rails
3
- VERSION = "1.2.2"
3
+ VERSION = "1.3.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: popularable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff McFadden