diff --git a/lib/statistics/aggregation.rb b/lib/statistics/aggregation.rb index 1d3115d92..d0dd74e6b 100644 --- a/lib/statistics/aggregation.rb +++ b/lib/statistics/aggregation.rb @@ -2,7 +2,8 @@ module Statistics class Aggregation def initialize(args) @from, @to = aggregation_period(args[:from], args[:to]) - dojos = fetch_dojos(args[:provider]) + @provider = args[:provider] + dojos = fetch_dojos(@provider) @externals = dojos[:externals] @internals = dojos[:internals] end @@ -86,9 +87,9 @@ def find_dojos_by(services) def with_notifying yield - Notifier.notify_success(date_format(@from), date_format(@to)) + Notifier.notify_success(date_format(@from), date_format(@to), @provider) rescue => e - Notifier.notify_failure(date_format(@from), date_format(@to), e) + Notifier.notify_failure(date_format(@from), date_format(@to), @provider, e) end def delete_event_histories @@ -119,16 +120,20 @@ def date_format(date) class Notifier class << self - def notify_success(from, to) - notify("#{from}~#{to}のイベント履歴の集計を行いました") + def notify_success(from, to, provider) + notify("#{from}~#{to}#{provider_info(provider)}のイベント履歴の集計を行いました") end - def notify_failure(from, to, exception) - notify("#{from}~#{to}のイベント履歴の集計でエラーが発生しました\n#{exception.message}\n#{exception.backtrace.join("\n")}") + def notify_failure(from, to, provider, exception) + notify("#{from}~#{to}#{provider_info(provider)}のイベント履歴の集計でエラーが発生しました\n#{exception.message}\n#{exception.backtrace.join("\n")}") end private + def provider_info(provider) + provider ? "(#{provider})" : nil + end + def idobata_hook_url return @idobata_hook_url if defined?(@idobata_hook_url) @idobata_hook_url = ENV['IDOBATA_HOOK_URL']