1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-17 06:52:27 +01:00

[bug] recurrent availabilities do not keep the custom duration

This commit is contained in:
Sylvain 2020-05-25 11:02:49 +02:00
parent 06cfaebe8d
commit bf57587301
3 changed files with 18 additions and 1 deletions

View File

@ -1,5 +1,8 @@
# Changelog Fab-manager
- Fix a bug: recurrent availabilities do not keep the custom duration
- [TODO DEPLOY] `rails fablab:fix:availabilities_duration`
## v4.4.2 2020 May 19
- Upgraded to ruby 2.6.5

View File

@ -21,7 +21,8 @@ class Availabilities::CreateAvailabilitiesService
training_ids: availability.training_ids,
space_ids: availability.space_ids,
tag_ids: availability.tag_ids,
nb_total_places: availability.nb_total_places
nb_total_places: availability.nb_total_places,
slot_duration: availability.slot_duration
).save!
end
end

View File

@ -174,5 +174,18 @@ namespace :fablab do
sp.save!
end
end
desc '[release 4.4.3] fix duration of recurring availabilities'
task availabilities_duration: :environment do
Availability.select(:occurrence_id).where(is_recurrent: true).group(:occurrence_id).each do |a|
occurrences = Availability.where(occurrence_id: a.occurrence_id)
next unless occurrences.map(&:slot_duration).uniq.size > 1
duration = occurrences.map(&:slot_duration).uniq.detect { |e| !e.nil? }
occurrences.each do |o|
o.update_attributes(slot_duration: duration)
end
end
end
end
end