datescope 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -2
- data/lib/datescope/base.rb +18 -2
- data/lib/datescope/version.rb +1 -1
- data/lib/datescope.rb +2 -2
- metadata +1 -1
data/README.md
CHANGED
@@ -26,8 +26,9 @@ Or install it yourself as:
|
|
26
26
|
|
27
27
|
end
|
28
28
|
|
29
|
-
|
30
|
-
|
29
|
+
User.registered.today.count
|
30
|
+
User.registered.last_month.all
|
31
|
+
User.registered.
|
31
32
|
|
32
33
|
|
33
34
|
## Contributing
|
data/lib/datescope/base.rb
CHANGED
@@ -2,11 +2,27 @@ module DateScope
|
|
2
2
|
|
3
3
|
module Extension
|
4
4
|
def today
|
5
|
-
where("created_at
|
5
|
+
where("created_at >= ?", 0.day.ago.beginning_of_day)
|
6
|
+
end
|
7
|
+
|
8
|
+
def this_week
|
9
|
+
where("created_at >= ?", 0.week.ago.beginning_of_week)
|
6
10
|
end
|
7
11
|
|
8
12
|
def this_month
|
9
|
-
where("created_at
|
13
|
+
where("created_at >= ?", 0.month.ago.beginning_of_month)
|
14
|
+
end
|
15
|
+
|
16
|
+
def last_month
|
17
|
+
where("created_at >= ? and created_ay <= ?", 1.month.ago.beginning_of_month, 1.month.ago.end_of_month)
|
18
|
+
end
|
19
|
+
|
20
|
+
def month_before_last_month
|
21
|
+
where("created_at >= ? and created_ay <= ?", 2.month.ago.beginning_of_month, 2.month.ago.end_of_month)
|
22
|
+
end
|
23
|
+
|
24
|
+
def this_year
|
25
|
+
where("created_at >= ?", 0.year.ago.beginning_of_year)
|
10
26
|
end
|
11
27
|
end
|
12
28
|
|
data/lib/datescope/version.rb
CHANGED
data/lib/datescope.rb
CHANGED