popularable 1.2.1 → 1.2.2
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.
- checksums.yaml +4 -4
- data/lib/concerns/popularable.rb +25 -0
- 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: d0745f50702b80911d1948e8b772f8790c5980c0
|
4
|
+
data.tar.gz: 09e203c343e1c476638c693d04ace162e4ef9d4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cb6bf92cb6139812a881f0a208017af720aa3a2736bd3981653fc2a32542d5d8482fbc493e7fac1b1607d5a99a5299a7aff9573079e522b721b76e6000e753e
|
7
|
+
data.tar.gz: dbd8b69f52684cd24fd3a048e5c3a989f2dc42a9d5d23365ab613e2700110b290ee1476e2f4fe849da2b05a0f4b3fc23ca3bb95c077a09ea1c6702fb27bf5905
|
data/lib/concerns/popularable.rb
CHANGED
@@ -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
|
|
data/lib/popularable/version.rb
CHANGED