Merge pull request #370 from ChrisBr/fix_migration
Assert event not deleted on add_events_per_week migration
This commit is contained in:
commit
0ca590a2e2
1 changed files with 44 additions and 40 deletions
|
|
@ -17,8 +17,10 @@ class AddEventsPerWeekToConference < ActiveRecord::Migration
|
|||
add_column :conferences, :events_per_week, :text
|
||||
|
||||
TempVersion.where(item_type: 'Event').each do |event_version|
|
||||
event = TempEvent.find(event_version.item_id)
|
||||
conference = TempConference.find(event.conference_id)
|
||||
event = TempEvent.find_by_id(event_version.item_id)
|
||||
if event
|
||||
conference = TempConference.find_by_id(event.conference_id)
|
||||
if conference
|
||||
week = event_version.created_at.end_of_week
|
||||
|
||||
no_events = {
|
||||
|
|
@ -64,10 +66,12 @@ class AddEventsPerWeekToConference < ActiveRecord::Migration
|
|||
end
|
||||
conference.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Cumulate the previous weeks to get a snapshot
|
||||
TempConference.all.each do |conference|
|
||||
hash = conference.events_per_week.sort.to_hash
|
||||
hash = conference.events_per_week.sort.to_h
|
||||
previous = nil
|
||||
|
||||
hash.each do |week, values|
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue