From bf57587301e38fcd31117d0dc8af432b832aea47 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Mon, 25 May 2020 11:02:49 +0200 Subject: [PATCH 1/2] [bug] recurrent availabilities do not keep the custom duration --- CHANGELOG.md | 3 +++ .../availabilities/create_availabilities_service.rb | 3 ++- lib/tasks/fablab/fix.rake | 13 +++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 38b542d17..42da13330 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/app/services/availabilities/create_availabilities_service.rb b/app/services/availabilities/create_availabilities_service.rb index 2afd49e11..da8891642 100644 --- a/app/services/availabilities/create_availabilities_service.rb +++ b/app/services/availabilities/create_availabilities_service.rb @@ -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 diff --git a/lib/tasks/fablab/fix.rake b/lib/tasks/fablab/fix.rake index 0d479b1e2..8b4918ea4 100644 --- a/lib/tasks/fablab/fix.rake +++ b/lib/tasks/fablab/fix.rake @@ -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 From 9522daee8066b76ad4d631df5c7e47454776b999 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Mon, 25 May 2020 11:23:39 +0200 Subject: [PATCH 2/2] Version 4.4.3 --- CHANGELOG.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42da13330..96bd5ae13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog Fab-manager +## v4.4.3 2020 May 25 + - Fix a bug: recurrent availabilities do not keep the custom duration - [TODO DEPLOY] `rails fablab:fix:availabilities_duration` diff --git a/package.json b/package.json index 631e53021..348167391 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fab-manager", - "version": "4.4.2", + "version": "4.4.3", "description": "Fab-manager is the FabLab management solution. It provides a comprehensive, web-based, open-source tool to simplify your administrative tasks and your marker's projects.", "keywords": [ "fablab",