Skip to content

Commit 1be3869

Browse files
committed
feat: 同じイベントサービスを共有する道場の開催日を同期
生駒と平群の道場は奈良と同じ Connpass イベントサービスを使用しているため、 活動状況ページで表示される開催日を奈良の情報と同期するようにしました。 変更内容: - sync_event_date プライベートメソッドを追加 - 生駒 (ID: 36) の開催日を奈良 (ID: 35) と同期 - 平群 (ID: 294) の開催日を奈良 (ID: 35) と同期 これにより、同じイベントで活動している道場の開催日が正しく表示されます。
1 parent 1fc2ec1 commit 1be3869

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

app/controllers/dojos_controller.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@ def activity
143143
}
144144
end
145145

146+
# 同じイベントサービスを共有している道場の開催日を同期
147+
# 生駒 (ID: 36) と平群 (ID: 294) は奈良 (ID: 35) と同じ connpass を使用
148+
sync_event_date(36, 35) # 生駒は奈良の開催日を参照
149+
sync_event_date(294, 35) # 平群は奈良の開催日を参照
150+
146151
# アクティブな道場と非アクティブな道場を分けてソート
147152
active_dojos = @latest_event_by_dojos.select { |d| d[:is_active] }
148153
inactive_dojos = @latest_event_by_dojos.reject { |d| d[:is_active] }
@@ -165,6 +170,19 @@ def activity
165170

166171
private
167172

173+
# 指定された道場の開催日を別の道場の開催日と同期する
174+
# @param target_dojo_id [Integer] 更新対象の道場ID
175+
# @param source_dojo_id [Integer] 参照元の道場ID
176+
def sync_event_date(target_dojo_id, source_dojo_id)
177+
source_dojo = @latest_event_by_dojos.find { |d| d[:id] == source_dojo_id }
178+
target_dojo = @latest_event_by_dojos.find { |d| d[:id] == target_dojo_id }
179+
180+
if source_dojo && target_dojo
181+
target_dojo[:latest_event_at] = source_dojo[:latest_event_at]
182+
target_dojo[:latest_event_url] = source_dojo[:latest_event_url]
183+
end
184+
end
185+
168186
def parse_date_from_note(date_match)
169187
return nil if date_match.nil?
170188

0 commit comments

Comments
 (0)