Skip to content

イベント履歴収集スクリプトでプロバイダ指定したとき、成功/失敗のメッセージにプロバイダを含める #396

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 12, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions lib/statistics/aggregation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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']
Expand Down