Skip to content

Commit d14608f

Browse files
committed
fix: Doorkeeperイベントデータのキーをシンボルに統一
Statistics::Tasks::Doorkeeperで文字列キーでアクセスしていたが、 EventService::Providers::Doorkeeperがシンボルキーで返すように 変更されたため、統計集計でDoorkeeperイベントが作成されない問題を修正。 また、テストスタブの日付を動的に生成するように変更し、 期間に応じた正しいイベント数が作成されるように調整した。
1 parent 66aa59d commit d14608f

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

lib/statistics/tasks/doorkeeper.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ def run
2020
dojo.dojo_event_services.for(:doorkeeper).each do |dojo_event_service|
2121
events = @client.fetch_events(**@params.merge(group_id: dojo_event_service.group_id))
2222
(events || []).compact.each do |e|
23-
next unless e['group'].to_s == dojo_event_service.group_id
23+
next unless e[:group].to_s == dojo_event_service.group_id
2424

2525
EventHistory.create!(dojo_id: dojo.id,
2626
dojo_name: dojo.name,
2727
service_name: dojo_event_service.name,
2828
service_group_id: dojo_event_service.group_id,
29-
event_id: e['id'],
30-
event_url: e['public_url'],
31-
participants: e['participants'],
32-
evented_at: Time.zone.parse(e['starts_at']))
29+
event_id: e[:id],
30+
event_url: e[:public_url],
31+
participants: e[:participants],
32+
evented_at: Time.zone.parse(e[:starts_at]))
3333
end
3434
end
3535
end

spec/support/shared_contexts/statistics.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,15 @@
8888
event: {
8989
title: "CoderDojo title",
9090
id: 1234,
91-
starts_at: "2017-05-28T01:00:00.000Z",
92-
ends_at: "2017-05-28T04:00:00.000Z",
91+
starts_at: (Time.zone.today.prev_month + 10.days).to_time.utc.iso8601,
92+
ends_at: (Time.zone.today.prev_month + 10.days + 3.hours).to_time.utc.iso8601,
9393
venue_name: "奥多摩町",
9494
address: "奥多摩町",
9595
lat: "35.801763000000",
9696
long: "139.087656000000",
9797
ticket_limit: 30,
98-
published_at: "2017-04-22T03:43:04.000Z",
99-
updated_at: "2017-05-10T11:31:21.810Z",
98+
published_at: (Time.zone.today.prev_month - 5.days).to_time.utc.iso8601,
99+
updated_at: (Time.zone.today.prev_month - 1.day).to_time.utc.iso8601,
100100
group: 5555,
101101
banner: nil,
102102
description: "CoderDojo description",

0 commit comments

Comments
 (0)