popularable 1.2.1 → 1.2.2

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: 6d5d0056f22c9c1348639c3b615db3f61184066d
4
- data.tar.gz: d54cf8bafe044acdcfa0858e272ad5d2a893ad47
3
+ metadata.gz: d0745f50702b80911d1948e8b772f8790c5980c0
4
+ data.tar.gz: 09e203c343e1c476638c693d04ace162e4ef9d4e
5
5
  SHA512:
6
- metadata.gz: 96b141d5644a04fc72a899d2b5287da8c3d11dc2bcc9da959ec54f1e95594486bf692fd1b889681074e584cf7bad3742fda17cc2fd13228caac48d1cf344bee8
7
- data.tar.gz: 790045a66684616d1d774c5e711b58b33dacc1aa63f9e27a01cc6558029221527908c095a77d9a23899e8b420dfb9f59de34a44813febb1dd29b6c060dadb831
6
+ metadata.gz: 5cb6bf92cb6139812a881f0a208017af720aa3a2736bd3981653fc2a32542d5d8482fbc493e7fac1b1607d5a99a5299a7aff9573079e522b721b76e6000e753e
7
+ data.tar.gz: dbd8b69f52684cd24fd3a048e5c3a989f2dc42a9d5d23365ab613e2700110b290ee1476e2f4fe849da2b05a0f4b3fc23ca3bb95c077a09ea1c6702fb27bf5905
@@ -34,6 +34,31 @@ module Popularable
34
34
  def self.has_popularable_concern?
35
35
  true
36
36
  end
37
+
38
+ # Count methods
39
+ def popular_count_today
40
+ popular_count_since(Time.now.beginning_of_day)
41
+ end
42
+
43
+ def popular_count_this_week
44
+ popular_count_since(Time.now.beginning_of_week)
45
+ end
46
+
47
+ def popular_count_this_month
48
+ popular_count_since(Time.now.beginning_of_month)
49
+ end
50
+
51
+ def popular_count_this_year
52
+ popular_count_since(Time.now.beginning_of_year)
53
+ end
54
+
55
+ def popular_count_all_time
56
+ popular_count_since(Time.now - 100.years)
57
+ end
58
+
59
+ def popular_count_since(since = Time.now)
60
+ popularable_popularity_events.where( "popularable_popularity_events.popularity_event_date >= ?", since.to_date ).sum( :popularity )
61
+ end
37
62
 
38
63
  end
39
64
 
@@ -1,5 +1,5 @@
1
1
  module Popularable
2
2
  module Rails
3
- VERSION = "1.2.1"
3
+ VERSION = "1.2.2"
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.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff McFadden