punching_bag 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/punching_bag/version.rb +1 -1
- data/lib/tasks/punching_bag.rake +25 -23
- metadata +4 -4
data/lib/punching_bag/version.rb
CHANGED
data/lib/tasks/punching_bag.rake
CHANGED
@@ -1,29 +1,31 @@
|
|
1
1
|
namespace :punching_bag do
|
2
|
-
|
3
2
|
desc 'Combine old hit records together to improve performance'
|
4
3
|
task :combine, [:by_day_after, :by_month_after, :by_year_after] => [:environment] do |t, args|
|
5
|
-
args.with_defaults :by_day_after => 7, :by_month_after => 1, :by_year_after => 1
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
4
|
+
args.with_defaults :by_day_after => 7, :by_month_after => 1, :by_year_after => 1
|
5
|
+
|
6
|
+
punchable_types = Punch.uniq.pluck(:punchable_type)
|
7
|
+
|
8
|
+
punchable_types.each do |punchable_type|
|
9
|
+
punchable_ids = Punch.uniq.where(punchable_type: punchable_type).pluck(:punchable_id)
|
10
|
+
|
11
|
+
punchable_ids.each do |punchable_id|
|
12
|
+
punchable = punchable_type.constantize.find(punchable_id)
|
13
|
+
|
14
|
+
# by_year
|
15
|
+
punchable.punches.before(args[:by_year_after].years.ago).each do |punch|
|
16
|
+
punch.combine_by_year
|
17
|
+
end
|
18
|
+
|
19
|
+
# by_month
|
20
|
+
punchable.punches.before(args[:by_month_after].months.ago).each do |punch|
|
21
|
+
punch.combine_by_month
|
22
|
+
end
|
23
|
+
|
24
|
+
# by_day
|
25
|
+
punchable.punches.before(args[:by_day_after].days.ago).each do |punch|
|
26
|
+
punch.combine_by_day
|
27
|
+
end
|
23
28
|
end
|
24
|
-
|
25
29
|
end
|
26
|
-
|
27
30
|
end
|
28
|
-
|
29
|
-
end
|
31
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: punching_bag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 3
|
10
|
+
version: 0.3.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Adam Crownoble
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2013-06-
|
18
|
+
date: 2013-06-06 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: voight_kampff
|