mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-17 06:52:27 +01:00
(bug) statistics not built
for instances with plans created before v4.3.3, the StatisticType.key does not match Plan.duration because of a behavior change in rails framework. (v4.3.3 introduces a framework upgrade)
This commit is contained in:
parent
193ee4ffe9
commit
e4a0798b8a
@ -1,7 +1,9 @@
|
||||
# Changelog Fab-manager
|
||||
|
||||
- Fix a bug: statistics not built for instances with plans created before v4.3.3
|
||||
- Fix a bug: when requesting to send the sso migration code, the email was case-sensitive.
|
||||
- Fix a bug: the adminsys email was case-sensitive.
|
||||
- [TODO DEPLOY] `rails fablab:maintenance:regenerate_statistics[2020,04]`
|
||||
|
||||
# v5.3.1 2022 January 17
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module StatConcern
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
@ -12,7 +14,7 @@ module StatConcern
|
||||
attribute :group, String
|
||||
|
||||
# has include Elasticsearch::Persistence::Model
|
||||
index_name "stats"
|
||||
document_type self.to_s.demodulize.underscore
|
||||
index_name 'stats'
|
||||
document_type to_s.demodulize&.underscore
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,33 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# From Fab-manager v4.3.3, the behavior of ActiveSupport::Duration#to_i has changed.
|
||||
# Previously, a month = 30 days, from since a month = 30.436875 days.
|
||||
# Also, previously a year = 365.25 days, from since a year = 365.2425 days.
|
||||
# This introduced a bug due to the key of the statistic types for subscriptions were equal to
|
||||
# the number of seconds of the plan duration, but this duration has changed due to the
|
||||
# change reported above.
|
||||
# This migration fixes the problem by changing the key of the statistic types for subscriptions
|
||||
# to the new plans durations.
|
||||
class FixSubscriptionStatisticTypes < ActiveRecord::Migration[5.2]
|
||||
def up
|
||||
one_month = 2_592_000
|
||||
(1..12).each do |n|
|
||||
StatisticType.where(key: (one_month * n).to_s).update_all(key: n.months.to_i)
|
||||
end
|
||||
one_year = 31_557_600
|
||||
(1..10).each do |n|
|
||||
StatisticType.where(key: (one_year * n).to_s).update_all(key: n.years.to_i)
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
one_month = 2_592_000
|
||||
(1..12).each do |n|
|
||||
StatisticType.where(key: n.months.to_i.to_s).update_all(key: (one_month * n).to_i)
|
||||
end
|
||||
one_year = 31_557_600
|
||||
(1..10).each do |n|
|
||||
StatisticType.where(key: n.years.to_i).update_all(key: (one_year * n).to_s)
|
||||
end
|
||||
end
|
||||
end
|
@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2022_01_11_134253) do
|
||||
ActiveRecord::Schema.define(version: 2022_01_18_123741) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "fuzzystrmatch"
|
||||
|
Loading…
x
Reference in New Issue
Block a user