File tree Expand file tree Collapse file tree 1 file changed +18
-8
lines changed Expand file tree Collapse file tree 1 file changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,10 @@ namespace :statistics do
16
16
d
17
17
}
18
18
19
+ notify_idobata = -> ( msg ) {
20
+ puts `curl --data-urlencode "source=#{ msg } " -s #{ ENV [ 'IDOBATA_HOOK_URL' ] } -o /dev/null -w "idobata: %{http_code}"` if ENV . key? ( 'IDOBATA_HOOK_URL' )
21
+ }
22
+
19
23
from = if args [ :from ]
20
24
if args [ :from ] . length == 4
21
25
date_from_str . call ( args [ :from ] ) . beginning_of_year
@@ -39,14 +43,20 @@ namespace :statistics do
39
43
40
44
EventHistory . where ( evented_at : from ..to ) . delete_all
41
45
42
- loop . with_object ( [ from ] ) { |_ , list |
43
- nm = list . last . next_month
44
- raise StopIteration if nm > to
45
- list << nm
46
- } . each { |date |
47
- puts "Aggregate for #{ date . strftime ( '%Y/%m' ) } "
48
- Statistics ::Aggregation . run ( date : date )
49
- }
46
+ begin
47
+ loop . with_object ( [ from ] ) { |_ , list |
48
+ nm = list . last . next_month
49
+ raise StopIteration if nm > to
50
+ list << nm
51
+ } . each { |date |
52
+ puts "Aggregate for #{ date . strftime ( '%Y/%m' ) } "
53
+ Statistics ::Aggregation . run ( date : date )
54
+ }
55
+
56
+ notify_idobata . call ( "#{ from . strftime ( '%Y/%m' ) } ~#{ to . strftime ( '%Y/%m' ) } のイベント履歴の集計を行いました" )
57
+ rescue
58
+ notify_idobata . call ( "#{ from . strftime ( '%Y/%m' ) } ~#{ to . strftime ( '%Y/%m' ) } のイベント履歴の集計でエラーが発生しました" )
59
+ end
50
60
end
51
61
52
62
desc 'キーワードからイベント情報を検索します'
You can’t perform that action at this time.
0 commit comments