diff --git a/.fabmanager-version b/.fabmanager-version index e128db9d6..08e8b22de 100644 --- a/.fabmanager-version +++ b/.fabmanager-version @@ -1 +1 @@ -2.5.12 \ No newline at end of file +2.5.13 \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 626357ad7..ce595d0b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,13 @@ # Changelog Fab Manager +## v2.5.13 2017 September 11 + +- Fix a bug: ActiveRecord::RecordNotFound when running rake task fix:recursive_events_over_DST with recursive events which the initial event was deleted + ## v2.5.12 2017 September 11 - Fix a bug: Long words overflow from homepage's events blocks -- Fix a bug: ActiveRecord::RecordNotFound when running rake task fix:recursive_events_over_DST +- Fix a bug: ActiveRecord::RecordNotFound when running rake task fix:recursive_events_over_DST with non-recursive events ## v2.5.11 2017 September 7 diff --git a/lib/tasks/fablab/fix.rake b/lib/tasks/fablab/fix.rake index ef358a502..4b66e78aa 100644 --- a/lib/tasks/fablab/fix.rake +++ b/lib/tasks/fablab/fix.rake @@ -60,11 +60,12 @@ namespace :fablab do task recursive_events_over_DST: :environment do include ApplicationHelper + failed_ids = [] groups = Event.group(:recurrence_id).count groups.keys.each do |recurrent_event_id| if recurrent_event_id - initial_event = Event.find(recurrent_event_id) - if initial_event + begin + initial_event = Event.find(recurrent_event_id) Event.where(recurrence_id: recurrent_event_id).where.not(id: recurrent_event_id).each do |event| availability = event.availability if initial_event.availability.start_at.hour != availability.start_at.hour @@ -73,11 +74,16 @@ namespace :fablab do availability.save! end end - else - puts "Error: The initial event (id: #{recurrent_event_id}) of the recurrence was not found. You may have to correct events manually" + rescue ActiveRecord::RecordNotFound + failed_ids.push recurrent_event_id end end end + + if failed_ids.size > 0 + puts "WARNING: The events with IDs #{failed_ids} were not found.\n These were initial events of a recurrence.\n\n You may have to correct the following events manually (IDs): " + puts "#{Events.where(recurrence_id: failed_ids).map(&:id)}" + end end end end