1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-28 09:24:24 +01:00

[ongoing] rake task to fix existing recursive events

This commit is contained in:
Sylvain 2017-09-04 17:27:18 +02:00
parent 31cdc5c695
commit 1af07f5e54
2 changed files with 16 additions and 0 deletions

View File

@ -12,6 +12,7 @@
- Updated puma for compatibility with openSSL > 1.0
- Documented installation on ArchLinux
- [TODO DEPLOY] `rake db:seed` then `rake fablab:fix:migrate_admins_group`
- [TODO DEPLAY] `rake fablab:fix:recursive_events_over_DST`
## v2.5.10 2017 August 16

View File

@ -57,5 +57,20 @@ namespace :fablab do
end
end
end
task recursive_events_over_DST: :environment do
#TODO intensive testing before release
include ApplicationHelper
groups = Event.group(:recurrence_id).count
groups.keys.each do |recurrent_event_id|
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
availability.start_at = dst_correction(initial_event.availability.start_at, availability.start_at)
availability.end_at = dst_correction(initial_event.availability.end_at, availability.end_at)
availability.save!
end
end
end
end
end