From adda8415831d348631aa9d4f2ae72fe4d30d2166 Mon Sep 17 00:00:00 2001 From: Chikako OHNO Date: Fri, 8 Mar 2019 00:33:08 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=A4=E3=83=99=E3=83=B3=E3=83=88=E5=B1=A5?= =?UTF-8?q?=E6=AD=B4=E5=8F=8E=E9=9B=86=E3=82=B9=E3=82=AF=E3=83=AA=E3=83=97?= =?UTF-8?q?=E3=83=88=E3=81=A7=E3=83=97=E3=83=AD=E3=83=90=E3=82=A4=E3=83=80?= =?UTF-8?q?=E6=8C=87=E5=AE=9A=E3=81=97=E3=81=9F=E3=81=A8=E3=81=8D=E3=80=81?= =?UTF-8?q?=E6=88=90=E5=8A=9F/=E5=A4=B1=E6=95=97=E3=81=AE=E3=83=A1?= =?UTF-8?q?=E3=83=83=E3=82=BB=E3=83=BC=E3=82=B8=E3=81=AB=E3=83=97=E3=83=AD?= =?UTF-8?q?=E3=83=90=E3=82=A4=E3=83=80=E3=82=92=E5=90=AB=E3=82=81=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/statistics/aggregation.rb | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) 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']