mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-19 13:54:25 +01:00
[bug] change plan price lost stats
This commit is contained in:
parent
8b8d161edd
commit
4f3c5e963c
@ -6,6 +6,8 @@
|
||||
- Fix a bug: when many users with too many unread notifications are connected at the same time, the system kill the application due to memory overflow
|
||||
- Fix a bug: ReservationReminderWorker crash with undefined method find_by
|
||||
- Fix a bug: navigation to about page duplicates admin's links in left menu
|
||||
- Fix a bug: changing the price of a plan lost its past statistics
|
||||
- [TODO DEPLOY] `rake fablab:set_plans_slugs`
|
||||
|
||||
## v2.4.9 2017 January 4
|
||||
|
||||
@ -21,7 +23,7 @@
|
||||
- Fix a bug: when deleting an availability just after its creation, the indexer workers crash and retries for a month
|
||||
- [TODO DEPLOY] remove possible value `application/` in `ALLOWED_MIME_TYPES` list, in environment variable
|
||||
- [TODO DEPLOY] `rails runner StatisticCustomAggregation.destroy_all`, then `rake db:seed`, then `rake fablab:es_build_availabilities_index` (1)
|
||||
- [TODO DEPLOY] `fablab:generate_stats[1095]` if you already has regenerated the statistics in the past, then they are very likely corrupted. Run this task to fix (2)
|
||||
- [TODO DEPLOY] `rake fablab:generate_stats[1095]` if you already has regenerated the statistics in the past, then they are very likely corrupted. Run this task to fix (2)
|
||||
|
||||
## v2.4.8 2016 December 15
|
||||
|
||||
|
@ -9,6 +9,9 @@ class Plan < ActiveRecord::Base
|
||||
has_one :plan_file, as: :viewable, dependent: :destroy
|
||||
has_many :prices, dependent: :destroy
|
||||
|
||||
extend FriendlyId
|
||||
friendly_id :name, use: :slugged
|
||||
|
||||
accepts_nested_attributes_for :prices
|
||||
accepts_nested_attributes_for :plan_file, allow_destroy: true, reject_if: :all_blank
|
||||
|
||||
@ -94,7 +97,7 @@ class Plan < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def create_statistic_subtype
|
||||
StatisticSubType.create!({key: self.stp_plan_id, label: self.name})
|
||||
StatisticSubType.create!({key: self.slug, label: self.name})
|
||||
end
|
||||
|
||||
def create_statistic_association(stat_type, stat_subtype)
|
||||
|
@ -12,7 +12,7 @@ class StatisticService
|
||||
Stats::Subscription.create({
|
||||
date: format_date(s.date),
|
||||
type: s.duration,
|
||||
subType: s.stp_plan_id,
|
||||
subType: s.slug,
|
||||
stat: 1,
|
||||
ca: s.ca,
|
||||
planId: s.plan_id,
|
||||
@ -138,7 +138,7 @@ class StatisticService
|
||||
plan_interval: p.interval,
|
||||
plan_interval_count: p.interval_count,
|
||||
plan_group_name: p.group.name,
|
||||
stp_plan_id: p.stp_plan_id,
|
||||
slug: p.slug,
|
||||
duration: p.duration.to_i,
|
||||
subscription_id: sub.id,
|
||||
invoice_item_id: i.id,
|
||||
|
5
db/migrate/20170109085345_add_slug_to_plan.rb
Normal file
5
db/migrate/20170109085345_add_slug_to_plan.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class AddSlugToPlan < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :plans, :slug, :string
|
||||
end
|
||||
end
|
13
db/schema.rb
13
db/schema.rb
@ -11,12 +11,12 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20161123104604) do
|
||||
ActiveRecord::Schema.define(version: 20170109085345) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
enable_extension "unaccent"
|
||||
enable_extension "pg_trgm"
|
||||
enable_extension "unaccent"
|
||||
|
||||
create_table "abuses", force: :cascade do |t|
|
||||
t.integer "signaled_id"
|
||||
@ -289,7 +289,7 @@ ActiveRecord::Schema.define(version: 20161123104604) do
|
||||
t.boolean "is_read", default: false
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "receiver_type", limit: 255
|
||||
t.string "receiver_type"
|
||||
t.boolean "is_send", default: false
|
||||
t.jsonb "meta_data", default: {}
|
||||
end
|
||||
@ -374,6 +374,7 @@ ActiveRecord::Schema.define(version: 20161123104604) do
|
||||
t.string "base_name"
|
||||
t.integer "ui_weight", default: 0
|
||||
t.integer "interval_count", default: 1
|
||||
t.string "slug"
|
||||
end
|
||||
|
||||
add_index "plans", ["group_id"], name: "index_plans_on_group_id", using: :btree
|
||||
@ -466,7 +467,7 @@ ActiveRecord::Schema.define(version: 20161123104604) do
|
||||
t.datetime "published_at"
|
||||
end
|
||||
|
||||
add_index "projects", ["slug"], name: "index_projects_on_slug", unique: true, using: :btree
|
||||
add_index "projects", ["slug"], name: "index_projects_on_slug", using: :btree
|
||||
|
||||
create_table "projects_components", force: :cascade do |t|
|
||||
t.integer "project_id"
|
||||
@ -535,8 +536,8 @@ ActiveRecord::Schema.define(version: 20161123104604) do
|
||||
t.datetime "updated_at"
|
||||
t.integer "availability_id"
|
||||
t.datetime "ex_start_at"
|
||||
t.datetime "canceled_at"
|
||||
t.datetime "ex_end_at"
|
||||
t.datetime "canceled_at"
|
||||
t.boolean "offered", default: false
|
||||
end
|
||||
|
||||
@ -718,7 +719,6 @@ ActiveRecord::Schema.define(version: 20161123104604) do
|
||||
add_index "user_trainings", ["user_id"], name: "index_user_trainings_on_user_id", using: :btree
|
||||
|
||||
create_table "users", force: :cascade do |t|
|
||||
t.string "username", limit: 255
|
||||
t.string "email", limit: 255, default: "", null: false
|
||||
t.string "encrypted_password", limit: 255, default: "", null: false
|
||||
t.string "reset_password_token", limit: 255
|
||||
@ -741,6 +741,7 @@ ActiveRecord::Schema.define(version: 20161123104604) do
|
||||
t.boolean "is_allow_contact", default: true
|
||||
t.integer "group_id"
|
||||
t.string "stp_customer_id", limit: 255
|
||||
t.string "username", limit: 255
|
||||
t.string "slug", limit: 255
|
||||
t.boolean "is_active", default: true
|
||||
t.boolean "invoicing_disabled", default: false
|
||||
|
@ -269,4 +269,14 @@ namespace :fablab do
|
||||
StatisticService.new.generate_statistic({start_date: i.day.ago.beginning_of_day,end_date: i.day.ago.end_of_day})
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
desc 'set slugs to plans'
|
||||
task set_plans_slugs: :environment do
|
||||
# this will maintain compatibility with existing statistics
|
||||
Plan.all.each do |p|
|
||||
p.slug = p.stp_plan_id
|
||||
p.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user