mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-20 14:54:15 +01:00
(bug) unable to update a training's title
This commit is contained in:
parent
1205cb925c
commit
95a5a18600
@ -6,6 +6,7 @@
|
||||
- Improved public calendar loading time
|
||||
- Fix a bug: event image updates are not reflected unless the browser's cache is purged
|
||||
- Fix a bug: schedules jobs are not launched at the right time
|
||||
- Fix a bug: unable to update the title of a training
|
||||
- [TODO DEPLOY] `rails fablab:fix_availabilities` THEN `rails fablab:setup:build_places_cache`
|
||||
- [TODO DEPLOY] `\curl -sSL https://raw.githubusercontent.com/sleede/fab-manager/master/scripts/rename-supporting-document.sh | bash`
|
||||
|
||||
|
@ -98,11 +98,11 @@ class Plan < ApplicationRecord
|
||||
|
||||
# must be publicly accessible for the migration
|
||||
def create_statistic_type
|
||||
stat_index = StatisticIndex.where(es_type_key: 'subscription')
|
||||
stat_index = StatisticIndex.find_by(es_type_key: 'subscription')
|
||||
type = find_statistic_type
|
||||
if type.nil?
|
||||
type = StatisticType.create!(
|
||||
statistic_index_id: stat_index.first.id,
|
||||
statistic_index_id: stat_index.id,
|
||||
key: duration.to_i,
|
||||
label: "#{I18n.t('statistics.duration')} : #{human_readable_duration}",
|
||||
graph: true,
|
||||
@ -114,11 +114,11 @@ class Plan < ApplicationRecord
|
||||
end
|
||||
|
||||
def find_statistic_type
|
||||
stat_index = StatisticIndex.where(es_type_key: 'subscription')
|
||||
type = StatisticType.find_by(statistic_index_id: stat_index.first.id, key: duration.to_i)
|
||||
stat_index = StatisticIndex.find_by(es_type_key: 'subscription')
|
||||
type = StatisticType.find_by(statistic_index_id: stat_index.id, key: duration.to_i)
|
||||
return type if type
|
||||
|
||||
StatisticType.where(statistic_index_id: stat_index.first.id).where('label LIKE ?', "%#{human_readable_duration}%").first
|
||||
StatisticType.where(statistic_index_id: stat_index.id).where('label LIKE ?', "%#{human_readable_duration}%").first
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -52,9 +52,9 @@ class Training < ApplicationRecord
|
||||
end
|
||||
|
||||
def update_statistic_subtype
|
||||
index = StatisticIndex.where(es_type_key: 'training')
|
||||
index = StatisticIndex.find_by(es_type_key: 'training')
|
||||
subtype = StatisticSubType.joins(statistic_type_sub_types: :statistic_type)
|
||||
.find_by(key: slug, statistic_types: { statistic_index_id: index.id })
|
||||
.find_by!(key: slug, statistic_types: { statistic_index_id: index.id })
|
||||
subtype.update(label: name)
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user