mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-20 14:54:15 +01:00
Merge branch 'dev' for release 6.3.0
This commit is contained in:
commit
75ced8fd9f
3
.gitignore
vendored
3
.gitignore
vendored
@ -77,3 +77,6 @@ yarn-debug.log*
|
||||
/yarn-error.log
|
||||
yarn-debug.log*
|
||||
.yarn-integrity
|
||||
|
||||
*.sql
|
||||
*.tar.gz
|
14
CHANGELOG.md
14
CHANGELOG.md
@ -1,5 +1,19 @@
|
||||
# Changelog Fab-manager
|
||||
|
||||
## v6.3.0 2023 November 3
|
||||
|
||||
- Fix a bug: fix all failing tasks of rake task file chain.rake
|
||||
- Fix a bug: file_size_validator.rb was broken since ruby v3, see https://github.com/rails/rails/issues/41270
|
||||
- improvement: pre-registration event reservations ilimit places
|
||||
- improvement: add including_deleted_users param for open api users
|
||||
- decreases sidekiq concurrency from 25 to 5, 25 is too much and consumes memory for nothing
|
||||
- do not log Notifications#polling action anymore, by default, can be enable via env variable ENABLE_NOTIFICATIONS_POLLING_LOGGING=true
|
||||
- Fix a bug: api/products/index bug when sorting by amount
|
||||
- adds a rake task to regenerate invoices by ids (see maintenance.rake)
|
||||
- Fix a bug: replaces custom ServerLocale middleware with sidekiq i18n middleware
|
||||
- adds a rake task to erase all reservations and invoices (fablab:maintenance:delete_all_reservations_and_invoices)
|
||||
- improvement: dynamic label (i18n) for stats structure tables
|
||||
|
||||
## v6.2.0 2023 October 13
|
||||
|
||||
- Fix a bug: fix ReservationReminderWorker, was sending reservation reminder to users with a event reservation not validated by admin + adds tests for all scenarios
|
||||
|
1
Gemfile
1
Gemfile
@ -153,3 +153,4 @@ gem 'sentry-ruby'
|
||||
gem "reverse_markdown"
|
||||
|
||||
gem "ancestry"
|
||||
gem 'silencer', require: false
|
@ -462,6 +462,7 @@ GEM
|
||||
concurrent-ruby (~> 1.0, >= 1.0.5)
|
||||
sidekiq (>= 5.0, < 8.0)
|
||||
thor (>= 0.20, < 3.0)
|
||||
silencer (2.0.0)
|
||||
simplecov (0.19.0)
|
||||
docile (~> 1.1)
|
||||
simplecov-html (~> 0.11)
|
||||
@ -611,6 +612,7 @@ DEPENDENCIES
|
||||
sidekiq (>= 6.0.7)
|
||||
sidekiq-scheduler
|
||||
sidekiq-unique-jobs (~> 7.1.23)
|
||||
silencer
|
||||
spring (~> 4)
|
||||
spring-watcher-listen (~> 2.1.0)
|
||||
stripe (= 5.29.0)
|
||||
|
@ -52,9 +52,9 @@ class API::NotificationsController < API::APIController
|
||||
|
||||
def polling
|
||||
@notifications = current_user.notifications
|
||||
.with_valid_notification_type
|
||||
.where('notifications.is_read = false AND notifications.created_at >= :date', date: params[:last_poll])
|
||||
.order('notifications.created_at DESC')
|
||||
.with_valid_notification_type
|
||||
.where('notifications.is_read = false AND notifications.created_at >= :date', date: params[:last_poll])
|
||||
.order('notifications.created_at DESC')
|
||||
@totals = {
|
||||
total: current_user.notifications.with_valid_notification_type.delivered_in_system(current_user).count,
|
||||
unread: current_user.notifications.with_valid_notification_type.delivered_in_system(current_user).where(is_read: false).count
|
||||
|
@ -7,7 +7,9 @@ class OpenAPI::V1::UsersController < OpenAPI::V1::BaseController
|
||||
expose_doc
|
||||
|
||||
def index
|
||||
@users = User.order(created_at: :desc).includes(:group, :profile, :invoicing_profile)
|
||||
@users = InvoicingProfile.order(created_at: :desc).includes(user: %i[group profile statistic_profile])
|
||||
|
||||
@users = @users.where.not(user_id: nil) if params[:including_deleted_users].blank?
|
||||
|
||||
if params[:email].present?
|
||||
email_param = params[:email].is_a?(String) ? params[:email].downcase : params[:email].map(&:downcase)
|
||||
|
@ -18,6 +18,7 @@ class OpenAPI::V1::UsersDoc < OpenAPI::V1::BaseDoc
|
||||
param :email, [String, Array], optional: true, desc: 'Filter users by *email* using strict matching.'
|
||||
param :user_id, [Integer, Array], optional: true, desc: 'Filter users by *id* using strict matching.'
|
||||
param :created_after, DateTime, optional: true, desc: 'Filter users to accounts created after the given date.'
|
||||
param :including_deleted_users, [true, false], optional: true, desc: 'Filter users to accounts deleted or not.'
|
||||
example <<-USERS
|
||||
# /open_api/v1/users?page=1&per_page=4
|
||||
{
|
||||
|
@ -1023,9 +1023,6 @@ Application.Controllers.controller('ShowEventController', ['$scope', '$state', '
|
||||
});
|
||||
resetEventReserve();
|
||||
});
|
||||
if ($scope.currentUser.role === 'admin') {
|
||||
return $scope.ctrl.member = null;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -60,7 +60,7 @@
|
||||
<div ng-if="!isCancelled(reservation) && !reservation.is_paid">
|
||||
<label class="m-r-sm">
|
||||
<span translate>{{ 'app.admin.event_reservations.negative' }}</span>
|
||||
<input type="radio" name="invalidate-{{reservation.id}}" ng-value="false" ng-click="invalidateReservation(reservation)" ng-model="reservation.slots_reservations_attributes[0].is_valid" ng-disabled="reservation.total_booked_seats > event.nb_free_places && !reservation.slots_reservations_attributes[0].is_valid">
|
||||
<input type="radio" name="invalidate-{{reservation.id}}" ng-value="false" ng-click="invalidateReservation(reservation)" ng-model="reservation.slots_reservations_attributes[0].is_valid" ng-disabled="reservation.slots_reservations_attributes[0].is_valid === 'false'">
|
||||
</label>
|
||||
<label>
|
||||
<span translate>{{ 'app.admin.event_reservations.affirmative' }}</span>
|
||||
|
@ -7,7 +7,6 @@ require 'json'
|
||||
class ChainedElement < ApplicationRecord
|
||||
belongs_to :element, polymorphic: true
|
||||
belongs_to :previous, class_name: 'ChainedElement'
|
||||
has_one :next, class_name: 'ChainedElement', inverse_of: :previous, dependent: :restrict_with_exception
|
||||
|
||||
before_create :set_content, :chain_record
|
||||
|
||||
|
9
app/models/concerns/label_i18n_concern.rb
Normal file
9
app/models/concerns/label_i18n_concern.rb
Normal file
@ -0,0 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module LabelI18nConcern
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def label
|
||||
super.present? ? super : I18n.t(label_i18n_path)
|
||||
end
|
||||
end
|
@ -69,7 +69,7 @@ class SlotsReservation < ApplicationRecord
|
||||
Slots::PlacesCacheService.change_places(target_slot,
|
||||
reservation.reservable_type,
|
||||
reservation.reservable_id,
|
||||
reservation.total_booked_seats,
|
||||
reservation.reservable.pre_registration ? 0 : reservation.total_booked_seats,
|
||||
operation)
|
||||
else
|
||||
Slots::PlacesCacheService.change_places(target_slot, reservation.reservable_type, reservation.reservable_id, 1, operation)
|
||||
|
@ -1,3 +1,5 @@
|
||||
class StatisticField < ApplicationRecord
|
||||
include LabelI18nConcern
|
||||
|
||||
has_one :statistic_index
|
||||
end
|
||||
|
@ -1,4 +1,6 @@
|
||||
class StatisticIndex < ApplicationRecord
|
||||
include LabelI18nConcern
|
||||
|
||||
has_many :statistic_types
|
||||
has_many :statistic_fields
|
||||
has_one :statistic_graph
|
||||
|
@ -1,4 +1,6 @@
|
||||
class StatisticSubType < ApplicationRecord
|
||||
include LabelI18nConcern
|
||||
|
||||
has_many :statistic_type_sub_types, dependent: :destroy
|
||||
has_many :statistic_types, through: :statistic_type_sub_types
|
||||
end
|
||||
|
@ -3,6 +3,8 @@
|
||||
# Allows splinting a StatisticIndex into multiple types.
|
||||
# e.g. The StatisticIndex "subscriptions" may have types like "1 month", "1 year", etc.
|
||||
class StatisticType < ApplicationRecord
|
||||
include LabelI18nConcern
|
||||
|
||||
belongs_to :statistic_index
|
||||
has_many :statistic_type_sub_types, dependent: :destroy
|
||||
has_many :statistic_sub_types, through: :statistic_type_sub_types
|
||||
|
@ -173,7 +173,7 @@ class ProductService
|
||||
order ||= 'desc'
|
||||
|
||||
if key == 'amount'
|
||||
products.order("COALESCE(amount, 0) #{order.upcase}")
|
||||
products.order(Arel.sql("COALESCE(amount, 0) #{order.upcase}"))
|
||||
else
|
||||
products.order(key => order)
|
||||
end
|
||||
|
@ -7,7 +7,7 @@ json.reservations @reservations do |reservation|
|
||||
json.user_id reservation.statistic_profile.user_id
|
||||
unless reservation.statistic_profile.user.nil?
|
||||
json.user do
|
||||
json.partial! 'open_api/v1/users/user', user: reservation.statistic_profile.user
|
||||
json.partial! 'open_api/v1/users/user', user: reservation.statistic_profile.user.invoicing_profile
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -7,7 +7,7 @@ json.user_trainings @user_trainings do |user_training|
|
||||
json.user_id user_training.statistic_profile.user_id
|
||||
unless user_training.statistic_profile.user.nil?
|
||||
json.user do
|
||||
json.partial! 'open_api/v1/users/user', user: user_training.statistic_profile.user
|
||||
json.partial! 'open_api/v1/users/user', user: user_training.statistic_profile.user.invoicing_profile
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,20 +1,22 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
json.extract! user, :id, :email, :created_at
|
||||
json.extract! user.profile, :full_name, :first_name, :last_name if user.association(:profile).loaded?
|
||||
json.gender user.statistic_profile.gender ? 'man' : 'woman'
|
||||
|
||||
if user.association(:invoicing_profile).loaded?
|
||||
json.invoicing_profile_id user.invoicing_profile.id
|
||||
json.external_id user.invoicing_profile.external_id
|
||||
json.organization !user.invoicing_profile.organization.nil?
|
||||
json.address user.invoicing_profile.invoicing_address
|
||||
json.id user.user_id || user.id
|
||||
json.extract! user, :email, :full_name, :first_name, :last_name, :created_at
|
||||
if user.user
|
||||
json.gender user.user.statistic_profile.gender ? 'man' : 'woman'
|
||||
else
|
||||
json.gender 'man'
|
||||
end
|
||||
|
||||
if user.association(:group).loaded?
|
||||
json.invoicing_profile_id user.id
|
||||
json.external_id user.external_id
|
||||
json.organization !user.organization.nil?
|
||||
json.address user.invoicing_address
|
||||
|
||||
if user&.user&.group
|
||||
json.group do
|
||||
if user.group_id?
|
||||
json.extract! user.group, :id, :name, :slug
|
||||
if user.user.group_id?
|
||||
json.extract! user.user.group, :id, :name, :slug
|
||||
else
|
||||
json.nil!
|
||||
end
|
||||
|
@ -3,7 +3,6 @@
|
||||
require 'sidekiq'
|
||||
require 'sidekiq-scheduler'
|
||||
require 'sidekiq/middleware/i18n'
|
||||
require 'sidekiq/server_locale'
|
||||
|
||||
redis_host = ENV.fetch('REDIS_HOST', 'localhost')
|
||||
redis_url = "redis://#{redis_host}:6379"
|
||||
@ -11,11 +10,17 @@ redis_url = "redis://#{redis_host}:6379"
|
||||
Sidekiq.configure_server do |config|
|
||||
config.redis = { url: redis_url }
|
||||
|
||||
# client_middleware is also configured in configure_server block
|
||||
# because jobs running in the Sidekiq server can themselves push
|
||||
# new jobs to Sidekiq, thus acting as clients
|
||||
# see https://github.com/sidekiq/sidekiq/wiki/Middleware for more details
|
||||
config.client_middleware do |chain|
|
||||
chain.add Sidekiq::Middleware::I18n::Client
|
||||
chain.add SidekiqUniqueJobs::Middleware::Client
|
||||
end
|
||||
|
||||
config.server_middleware do |chain|
|
||||
chain.add Sidekiq::Middleware::I18n::Server
|
||||
chain.add SidekiqUniqueJobs::Middleware::Server
|
||||
end
|
||||
|
||||
@ -36,11 +41,9 @@ Sidekiq.configure_client do |config|
|
||||
config.redis = { url: redis_url }
|
||||
|
||||
config.client_middleware do |chain|
|
||||
chain.add Sidekiq::Middleware::I18n::Client
|
||||
chain.add SidekiqUniqueJobs::Middleware::Client
|
||||
end
|
||||
config.server_middleware do |chain|
|
||||
chain.add FabManager::Middleware::ServerLocale
|
||||
end
|
||||
end
|
||||
|
||||
# Quieting logging in the test environment
|
||||
|
13
config/initializers/silencer.rb
Normal file
13
config/initializers/silencer.rb
Normal file
@ -0,0 +1,13 @@
|
||||
require 'silencer/rails/logger'
|
||||
|
||||
silenced_actions = []
|
||||
silenced_actions << "/api/notifications/polling" unless Rails.application.secrets.enable_notifications_polling_logging
|
||||
|
||||
Rails.application.configure do
|
||||
config.middleware.swap(
|
||||
Rails::Rack::Logger,
|
||||
Silencer::Logger,
|
||||
config.log_tags,
|
||||
silence: silenced_actions
|
||||
)
|
||||
end
|
@ -47,7 +47,7 @@ es:
|
||||
description: "Descripción"
|
||||
name: "Nombre"
|
||||
illustration: "Ilustración"
|
||||
illustration_recommendation: "Maximum display size: 932 * 700 px (unconstrained ratio). The image may be cropped in list view. Only the description page displays the full image."
|
||||
illustration_recommendation: "Tamaño máximo: 932 * 700 px (ratio sin restricciones). La imagen puede ser recortada en la vista de lista. Sólo la página de descripción muestra la imagen completa."
|
||||
technical_specifications: "Especificaciones técnicas"
|
||||
category: "Categoría"
|
||||
attachments: "Adjuntos"
|
||||
@ -67,8 +67,8 @@ es:
|
||||
dont_forget_to_change_them_before_creating_slots_for_this_training: "No olvide cambiarlos antes de crear franjas horarias para esta formación."
|
||||
description: "Descripción"
|
||||
name: "Nombre"
|
||||
illustration: "Visual"
|
||||
illustration_recommendation: "Maximum display size: 932 * 700 px (unconstrained ratio). The image may be cropped in list view. Only the description page displays the full image."
|
||||
illustration: "Ilustración"
|
||||
illustration_recommendation: "Tamaño máximo: 932 * 700 px (ratio sin restricciones). La imagen puede ser recortada en la vista de lista. Sólo la página de descripción muestra la imagen completa."
|
||||
add_a_new_training: "Añadir una nueva formación"
|
||||
validate_your_training: "Valide su formación"
|
||||
settings: "Configuración"
|
||||
@ -100,8 +100,8 @@ es:
|
||||
watch_out_when_creating_a_new_space_its_prices_are_initialized_at_0_for_all_subscriptions: "¡Cuidado! Al crear un nuevo espacio, sus precios se inicializan a 0 para todas las suscripciones."
|
||||
consider_changing_its_prices_before_creating_any_reservation_slot: "Considere cambiar sus precios antes de crear cualquier espacio de reserva."
|
||||
name: "Nombre"
|
||||
illustration: "Visual"
|
||||
illustration_recommendation: "Maximum display size: 932 * 700 px (unconstrained ratio). The image may be cropped in list view. Only the description page displays the full image."
|
||||
illustration: "Ilustración"
|
||||
illustration_recommendation: "Tamaño máximo: 932 * 700 px (ratio sin restricciones). La imagen puede ser recortada en la vista de lista. Sólo la página de descripción muestra la imagen completa."
|
||||
description: "Descripción"
|
||||
characteristics: "Características"
|
||||
attachments: "Adjuntos"
|
||||
@ -121,8 +121,8 @@ es:
|
||||
event_form:
|
||||
ACTION_title: "{ACTION, select, create{Nuevo} other{Actualiza el}} evento"
|
||||
title: "Título"
|
||||
illustration: "Visual"
|
||||
illustration_recommendation: "Maximum display size: 932 * 700 px (unconstrained ratio). The image may be cropped in list view. Only the description page displays the full image."
|
||||
illustration: "Ilustración"
|
||||
illustration_recommendation: "Tamaño máximo: 932 * 700 px (ratio sin restricciones). La imagen puede ser recortada en la vista de lista. Sólo la página de descripción muestra la imagen completa."
|
||||
description: "Descripción"
|
||||
attachments: "Adjuntos"
|
||||
attached_files_pdf: "Archivos adjuntos (pdf)"
|
||||
@ -1668,7 +1668,7 @@ es:
|
||||
secondary_colour: "Color secundario:"
|
||||
secondary: "Secundario"
|
||||
background_picture_of_the_profile_banner: "Imagen de fondo de la bandera del perfil"
|
||||
background_picture_recommendation: "Only .png file. Recommended size: 4/1 ratio, 1600*400 px."
|
||||
background_picture_recommendation: "Sólo archivo .png. Tamaño recomendado: 4/1, 1600*400 px."
|
||||
change_the_profile_banner: "Cambiar la bandera del perfil"
|
||||
home_page: "Página de inicio"
|
||||
news_of_the_home_page: "Noticias de la página principal:"
|
||||
|
@ -324,9 +324,9 @@ es:
|
||||
notify_admin_member_create_reservation: "Un miembro hace una reserva"
|
||||
notify_admin_slot_is_modified: "Una franja de reserva ha sido modificada"
|
||||
notify_admin_slot_is_canceled: "Una reserva ha sido cancelada"
|
||||
notify_admin_reservation_validated: "A reservation has been validated"
|
||||
notify_admin_reservation_invalidated: "A reservation has been invalidated"
|
||||
notify_admin_member_pre_booked_reservation: "A pre-booking has been made"
|
||||
notify_admin_reservation_validated: "Una reserva ha sido validada"
|
||||
notify_admin_reservation_invalidated: "Una reserva ha sido invalidada"
|
||||
notify_admin_member_pre_booked_reservation: "Se ha hecho una pre-reserva"
|
||||
notify_admin_subscribed_plan: "Se ha adquirido una suscripción"
|
||||
notify_admin_subscription_will_expire_in_7_days: "Una suscripción de miembro caduca en 7 días"
|
||||
notify_admin_subscription_is_expired: "La suscripción de un miembro ha expirado"
|
||||
|
@ -128,7 +128,7 @@ es:
|
||||
name: "Nombre"
|
||||
name_is_required: "Se requiere un nombre."
|
||||
illustration: "Ilustración"
|
||||
illustration_recommendation: "Maximum display size: 932 * 700 px (unconstrained ratio)."
|
||||
illustration_recommendation: "Tamaño máximo: 932 * 700 px (ratio sin restricciones)."
|
||||
add_an_illustration: "Añadir una ilustración"
|
||||
CAD_file: "Fichero CAD"
|
||||
CAD_files: "Archivos CAD"
|
||||
|
@ -43,6 +43,7 @@ development:
|
||||
adminsys_email: <%= ENV["ADMINSYS_EMAIL"] %>
|
||||
allow_insecure_http: <%= ENV.fetch("ALLOW_INSECURE_HTTP", false) %>
|
||||
locked_settings: <%= ENV.fetch("LOCKED_SETTINGS", 'uuid,origin').split(/,/) %>
|
||||
enable_notifications_polling_logging: <%= ENV.fetch("ENABLE_NOTIFICATIONS_POLLING_LOGGING", false) %>
|
||||
|
||||
test:
|
||||
secret_key_base: 83daf5e7b80d990f037407bab78dff9904aaf3c195a50f84fa8695a22287e707dfbd9524b403b1dcf116ae1d8c06844c3d7ed942564e5b46be6ae3ead93a9d30
|
||||
@ -75,6 +76,7 @@ test:
|
||||
adminsys_email: <%= ENV["ADMINSYS_EMAIL"] %>
|
||||
allow_insecure_http: <%= ENV.fetch("ALLOW_INSECURE_HTTP", false) %>
|
||||
locked_settings: <%= ENV.fetch("LOCKED_SETTINGS", 'uuid,origin').split(/,/) %>
|
||||
enable_notifications_polling_logging: <%= ENV.fetch("ENABLE_NOTIFICATIONS_POLLING_LOGGING", false) %>
|
||||
|
||||
staging:
|
||||
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
|
||||
@ -117,6 +119,7 @@ staging:
|
||||
enable_in_context_translation: <%= ENV["ENABLE_IN_CONTEXT_TRANSLATION"] %>
|
||||
allow_insecure_http: <%= ENV.fetch("ALLOW_INSECURE_HTTP", false) %>
|
||||
locked_settings: <%= ENV.fetch("LOCKED_SETTINGS", 'uuid,origin').split(/,/) %>
|
||||
enable_notifications_polling_logging: <%= ENV.fetch("ENABLE_NOTIFICATIONS_POLLING_LOGGING", false) %>
|
||||
|
||||
# Do not keep production secrets in the repository,
|
||||
# instead read values from the environment.
|
||||
@ -162,3 +165,4 @@ production:
|
||||
adminsys_email: <%= ENV["ADMINSYS_EMAIL"] %>
|
||||
allow_insecure_http: <%= ENV.fetch("ALLOW_INSECURE_HTTP", false) %>
|
||||
locked_settings: <%= ENV.fetch("LOCKED_SETTINGS", 'uuid,origin').split(/,/) %>
|
||||
enable_notifications_polling_logging: <%= ENV.fetch("ENABLE_NOTIFICATIONS_POLLING_LOGGING", false) %>
|
||||
|
@ -1,7 +1,7 @@
|
||||
# configuration file for Sidekiq
|
||||
:verbose: true
|
||||
:logfile: ./log/sidekiq.log
|
||||
:concurrency: 25
|
||||
:concurrency: 5
|
||||
:queues:
|
||||
- [stripe, 7]
|
||||
- [default, 5]
|
||||
|
@ -0,0 +1,99 @@
|
||||
class AddLabelI18nPathToStatisticTables < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
add_column :statistic_indices, :label_i18n_path, :string
|
||||
add_column :statistic_types, :label_i18n_path, :string
|
||||
add_column :statistic_sub_types, :label_i18n_path, :string
|
||||
add_column :statistic_fields, :label_i18n_path, :string
|
||||
|
||||
# StatisticIndex
|
||||
|
||||
statistic_index_subscription = StatisticIndex.find_by!(es_type_key: 'subscription')
|
||||
statistic_index_subscription.update!(label: nil, label_i18n_path: 'statistics.subscriptions')
|
||||
|
||||
statistic_index_machine = StatisticIndex.find_by!(es_type_key: 'machine')
|
||||
statistic_index_machine.update!(label: nil, label_i18n_path: 'statistics.machines_hours')
|
||||
|
||||
statistic_index_training = StatisticIndex.find_by!(es_type_key: 'training')
|
||||
statistic_index_training.update!(label: nil, label_i18n_path: 'statistics.trainings')
|
||||
|
||||
statistic_index_event = StatisticIndex.find_by!(es_type_key: 'event')
|
||||
statistic_index_event.update!(label: nil, label_i18n_path: 'statistics.events')
|
||||
|
||||
statistic_index_account = StatisticIndex.find_by!(es_type_key: 'account')
|
||||
statistic_index_account.update!(label: nil, label_i18n_path: 'statistics.registrations')
|
||||
|
||||
statistic_index_project = StatisticIndex.find_by!(es_type_key: 'project')
|
||||
statistic_index_project.update!(label: nil, label_i18n_path: 'statistics.projects')
|
||||
|
||||
statistic_index_user = StatisticIndex.find_by!(es_type_key: 'user')
|
||||
statistic_index_user.update!(label: nil, label_i18n_path: 'statistics.users')
|
||||
|
||||
statistic_index_space = StatisticIndex.find_by!(es_type_key: 'space')
|
||||
statistic_index_space.update!(label: nil, label_i18n_path: 'statistics.spaces')
|
||||
|
||||
statistic_index_order = StatisticIndex.find_by!(es_type_key: 'order')
|
||||
statistic_index_order.update!(label: nil, label_i18n_path: 'statistics.orders')
|
||||
|
||||
# StatisticField
|
||||
|
||||
StatisticField.find_by!(key: 'groupName', statistic_index_id: statistic_index_subscription.id).update!(label: nil, label_i18n_path: 'statistics.group')
|
||||
|
||||
StatisticField.find_by!(key: 'spaceDates', statistic_index_id: statistic_index_space.id).update!(label: nil, label_i18n_path: 'statistics.space_dates')
|
||||
StatisticField.find_by!(key: 'groupName', statistic_index_id: statistic_index_space.id).update!(label: nil, label_i18n_path: 'statistics.group')
|
||||
|
||||
StatisticField.find_by!(key: 'machineDates', statistic_index_id: statistic_index_machine.id).update!(label: nil, label_i18n_path: 'statistics.machine_dates')
|
||||
StatisticField.find_by!(key: 'groupName', statistic_index_id: statistic_index_machine.id).update!(label: nil, label_i18n_path: 'statistics.group')
|
||||
|
||||
|
||||
StatisticField.find_by!(key: 'trainingId', statistic_index_id: statistic_index_training.id).update!(label: nil, label_i18n_path: 'statistics.training_id')
|
||||
StatisticField.find_by!(key: 'trainingDate', statistic_index_id: statistic_index_training.id).update!(label: nil, label_i18n_path: 'statistics.training_date')
|
||||
StatisticField.find_by!(key: 'groupName', statistic_index_id: statistic_index_training.id).update!(label: nil, label_i18n_path: 'statistics.group')
|
||||
|
||||
StatisticField.find_by!(key: 'name', statistic_index_id: statistic_index_event.id).update!(label: nil, label_i18n_path: 'statistics.event_name')
|
||||
StatisticField.find_by!(key: 'eventId', statistic_index_id: statistic_index_event.id).update!(label: nil, label_i18n_path: 'statistics.event_id')
|
||||
StatisticField.find_by!(key: 'eventDate', statistic_index_id: statistic_index_event.id).update!(label: nil, label_i18n_path: 'statistics.event_date')
|
||||
StatisticField.find_by!(key: 'groupName', statistic_index_id: statistic_index_event.id).update!(label: nil, label_i18n_path: 'statistics.group')
|
||||
StatisticField.find_by!(key: 'eventTheme', statistic_index_id: statistic_index_event.id).update!(label: nil, label_i18n_path: 'statistics.event_theme')
|
||||
StatisticField.find_by!(key: 'ageRange', statistic_index_id: statistic_index_event.id).update!(label: nil, label_i18n_path: 'statistics.age_range')
|
||||
|
||||
StatisticField.find_by!(key: 'groupName', statistic_index_id: statistic_index_account.id).update!(label: nil, label_i18n_path: 'statistics.group')
|
||||
|
||||
StatisticField.find_by!(key: 'themes', statistic_index_id: statistic_index_project.id).update!(label: nil, label_i18n_path: 'statistics.themes')
|
||||
StatisticField.find_by!(key: 'components', statistic_index_id: statistic_index_project.id).update!(label: nil, label_i18n_path: 'statistics.components')
|
||||
StatisticField.find_by!(key: 'machines', statistic_index_id: statistic_index_project.id).update!(label: nil, label_i18n_path: 'statistics.machines')
|
||||
StatisticField.find_by!(key: 'status', statistic_index_id: statistic_index_project.id).update!(label: nil, label_i18n_path: 'statistics.project_status')
|
||||
StatisticField.find_by!(key: 'name', statistic_index_id: statistic_index_project.id).update!(label: nil, label_i18n_path: 'statistics.project_name')
|
||||
StatisticField.find_by!(key: 'projectUserNames', statistic_index_id: statistic_index_project.id).update!(label: nil, label_i18n_path: 'statistics.project_user_names')
|
||||
|
||||
StatisticField.find_by!(key: 'userId', statistic_index_id: statistic_index_user.id).update!(label: nil, label_i18n_path: 'statistics.user_id')
|
||||
|
||||
StatisticField.find_by!(key: 'groupName', statistic_index_id: statistic_index_order.id).update!(label: nil, label_i18n_path: 'statistics.group')
|
||||
|
||||
# StatisticType
|
||||
StatisticType.find_by!(key: 'booking', statistic_index_id: statistic_index_machine.id).update!(label: nil, label_i18n_path: 'statistics.bookings')
|
||||
StatisticType.find_by!(key: 'hour', statistic_index_id: statistic_index_machine.id).update!(label: nil, label_i18n_path: 'statistics.hours_number')
|
||||
|
||||
StatisticType.find_by!(key: 'booking', statistic_index_id: statistic_index_training.id).update!(label: nil, label_i18n_path: 'statistics.bookings')
|
||||
StatisticType.find_by!(key: 'hour', statistic_index_id: statistic_index_training.id).update!(label: nil, label_i18n_path: 'statistics.hours_number')
|
||||
|
||||
StatisticType.find_by!(key: 'booking', statistic_index_id: statistic_index_event.id).update!(label: nil, label_i18n_path: 'statistics.tickets_number')
|
||||
StatisticType.find_by!(key: 'hour', statistic_index_id: statistic_index_event.id).update!(label: nil, label_i18n_path: 'statistics.hours_number')
|
||||
|
||||
StatisticType.find_by!(key: 'member', statistic_index_id: statistic_index_account.id).update!(label: nil, label_i18n_path: 'statistics.users')
|
||||
|
||||
StatisticType.find_by!(key: 'project', statistic_index_id: statistic_index_project.id).update!(label: nil, label_i18n_path: 'statistics.projects')
|
||||
|
||||
StatisticType.find_by!(key: 'revenue', statistic_index_id: statistic_index_user.id).update!(label: nil, label_i18n_path: 'statistics.revenue')
|
||||
|
||||
StatisticType.find_by!(key: 'booking', statistic_index_id: statistic_index_space.id).update!(label: nil, label_i18n_path: 'statistics.bookings')
|
||||
StatisticType.find_by!(key: 'hour', statistic_index_id: statistic_index_space.id).update!(label: nil, label_i18n_path: 'statistics.hours_number')
|
||||
|
||||
StatisticType.find_by!(key: 'store', statistic_index_id: statistic_index_order.id).update!(label: nil, label_i18n_path: 'statistics.store')
|
||||
|
||||
# StatisticSubType
|
||||
StatisticSubType.find_by!(key: 'created').update!(label: nil, label_i18n_path: 'statistics.account_creation')
|
||||
StatisticSubType.find_by!(key: 'published').update!(label: nil, label_i18n_path: 'statistics.project_publication')
|
||||
StatisticSubType.find_by!(key: 'paid-processed').update!(label: nil, label_i18n_path: 'statistics.paid-rocessed')
|
||||
StatisticSubType.find_by!(key: 'aborted').update!(label: nil, label_i18n_path: 'statistics.aborted')
|
||||
end
|
||||
end
|
@ -4,141 +4,141 @@ require_relative '../../lib/database/sequence'
|
||||
|
||||
# statistic_indices
|
||||
unless StatisticIndex.find_by(es_type_key: 'subscription')
|
||||
StatisticIndex.create!({ id: 1, es_type_key: 'subscription', label: I18n.t('statistics.subscriptions') })
|
||||
StatisticIndex.create!({ id: 1, es_type_key: 'subscription', label_i18n_path: 'statistics.subscriptions' })
|
||||
end
|
||||
unless StatisticIndex.find_by(es_type_key: 'machine')
|
||||
StatisticIndex.create!({ id: 2, es_type_key: 'machine', label: I18n.t('statistics.machines_hours') })
|
||||
StatisticIndex.create!({ id: 2, es_type_key: 'machine', label_i18n_path: 'statistics.machines_hours' })
|
||||
end
|
||||
unless StatisticIndex.find_by(es_type_key: 'training')
|
||||
StatisticIndex.create!({ id: 3, es_type_key: 'training', label: I18n.t('statistics.trainings') })
|
||||
StatisticIndex.create!({ id: 3, es_type_key: 'training', label_i18n_path: 'statistics.trainings' })
|
||||
end
|
||||
StatisticIndex.create!({ id: 4, es_type_key: 'event', label: I18n.t('statistics.events') }) unless StatisticIndex.find_by(es_type_key: 'event')
|
||||
StatisticIndex.create!({ id: 4, es_type_key: 'event', label_i18n_path: 'statistics.events' }) unless StatisticIndex.find_by(es_type_key: 'event')
|
||||
unless StatisticIndex.find_by(es_type_key: 'account')
|
||||
StatisticIndex.create!({ id: 5, es_type_key: 'account', label: I18n.t('statistics.registrations'), ca: false })
|
||||
StatisticIndex.create!({ id: 5, es_type_key: 'account', label_i18n_path: 'statistics.registrations', ca: false })
|
||||
end
|
||||
unless StatisticIndex.find_by(es_type_key: 'project')
|
||||
StatisticIndex.create!({ id: 6, es_type_key: 'project', label: I18n.t('statistics.projects'), ca: false })
|
||||
StatisticIndex.create!({ id: 6, es_type_key: 'project', label_i18n_path: 'statistics.projects', ca: false })
|
||||
end
|
||||
unless StatisticIndex.find_by(es_type_key: 'user')
|
||||
StatisticIndex.create!({ id: 7, es_type_key: 'user', label: I18n.t('statistics.users'), table: false, ca: false })
|
||||
StatisticIndex.create!({ id: 7, es_type_key: 'user', label_i18n_path: 'statistics.users', table: false, ca: false })
|
||||
end
|
||||
Database::Sequence.update_id_seq(StatisticIndex.table_name)
|
||||
StatisticIndex.create!({ es_type_key: 'space', label: I18n.t('statistics.spaces') }) unless StatisticIndex.find_by(es_type_key: 'space')
|
||||
StatisticIndex.create!({ es_type_key: 'order', label: I18n.t('statistics.orders') }) unless StatisticIndex.find_by(es_type_key: 'order')
|
||||
StatisticIndex.create!({ es_type_key: 'space', label_i18n_path: 'statistics.spaces' }) unless StatisticIndex.find_by(es_type_key: 'space')
|
||||
StatisticIndex.create!({ es_type_key: 'order', label_i18n_path: 'statistics.orders' }) unless StatisticIndex.find_by(es_type_key: 'order')
|
||||
|
||||
statistic_index_space = StatisticIndex.find_by(es_type_key: 'space')
|
||||
statistic_index_order = StatisticIndex.find_by(es_type_key: 'order')
|
||||
|
||||
# statistic_fields
|
||||
unless StatisticField.find_by(key: 'spaceDates', statistic_index_id: statistic_index_space.id)
|
||||
StatisticField.create!({ key: 'spaceDates', label: I18n.t('statistics.space_dates'),
|
||||
StatisticField.create!({ key: 'spaceDates', label_i18n_path: 'statistics.space_dates',
|
||||
statistic_index_id: statistic_index_space.id, data_type: 'list' })
|
||||
end
|
||||
unless StatisticField.find_by(key: 'groupName', statistic_index_id: statistic_index_space.id)
|
||||
StatisticField.create!({ key: 'groupName', label: I18n.t('statistics.group'), statistic_index_id: statistic_index_space.id, data_type: 'text' })
|
||||
StatisticField.create!({ key: 'groupName', label_i18n_path: 'statistics.group', statistic_index_id: statistic_index_space.id, data_type: 'text' })
|
||||
end
|
||||
unless StatisticField.find_by(key: 'machineDates', statistic_index_id: 2)
|
||||
StatisticField.create!({ key: 'machineDates', label: I18n.t('statistics.machine_dates'), statistic_index_id: 2, data_type: 'list' })
|
||||
StatisticField.create!({ key: 'machineDates', label_i18n_path: 'statistics.machine_dates', statistic_index_id: 2, data_type: 'list' })
|
||||
end
|
||||
unless StatisticField.find_by(key: 'groupName', statistic_index_id: 2)
|
||||
StatisticField.create!({ key: 'groupName', label: I18n.t('statistics.group'), statistic_index_id: 2, data_type: 'text' })
|
||||
StatisticField.create!({ key: 'groupName', label_i18n_path: 'statistics.group', statistic_index_id: 2, data_type: 'text' })
|
||||
end
|
||||
unless StatisticField.find_by(key: 'trainingId', statistic_index_id: 3)
|
||||
StatisticField.create!({ key: 'trainingId', label: I18n.t('statistics.training_id'), statistic_index_id: 3, data_type: 'index' })
|
||||
StatisticField.create!({ key: 'trainingId', label_i18n_path: 'statistics.training_id', statistic_index_id: 3, data_type: 'index' })
|
||||
end
|
||||
unless StatisticField.find_by(key: 'trainingDate', statistic_index_id: 3)
|
||||
StatisticField.create!({ key: 'trainingDate', label: I18n.t('statistics.training_date'), statistic_index_id: 3, data_type: 'date' })
|
||||
StatisticField.create!({ key: 'trainingDate', label_i18n_path: 'statistics.training_date', statistic_index_id: 3, data_type: 'date' })
|
||||
end
|
||||
unless StatisticField.find_by(key: 'groupName', statistic_index_id: 3)
|
||||
StatisticField.create!({ key: 'groupName', label: I18n.t('statistics.group'), statistic_index_id: 3, data_type: 'text' })
|
||||
StatisticField.create!({ key: 'groupName', label_i18n_path: 'statistics.group', statistic_index_id: 3, data_type: 'text' })
|
||||
end
|
||||
unless StatisticField.find_by(key: 'eventId', statistic_index_id: 4)
|
||||
StatisticField.create!({ key: 'eventId', label: I18n.t('statistics.event_id'), statistic_index_id: 4, data_type: 'index' })
|
||||
StatisticField.create!({ key: 'eventId', label_i18n_path: 'statistics.event_id', statistic_index_id: 4, data_type: 'index' })
|
||||
end
|
||||
unless StatisticField.find_by(key: 'eventDate', statistic_index_id: 4)
|
||||
StatisticField.create!({ key: 'eventDate', label: I18n.t('statistics.event_date'), statistic_index_id: 4, data_type: 'date' })
|
||||
StatisticField.create!({ key: 'eventDate', label_i18n_path: 'statistics.event_date', statistic_index_id: 4, data_type: 'date' })
|
||||
end
|
||||
unless StatisticField.find_by(key: 'groupName', statistic_index_id: 4)
|
||||
StatisticField.create!({ key: 'groupName', label: I18n.t('statistics.group'), statistic_index_id: 4, data_type: 'text' })
|
||||
StatisticField.create!({ key: 'groupName', label_i18n_path: 'statistics.group', statistic_index_id: 4, data_type: 'text' })
|
||||
end
|
||||
unless StatisticField.find_by(key: 'groupName', statistic_index_id: 5)
|
||||
StatisticField.create!({ key: 'groupName', label: I18n.t('statistics.group'), statistic_index_id: 5, data_type: 'text' })
|
||||
StatisticField.create!({ key: 'groupName', label_i18n_path: 'statistics.group', statistic_index_id: 5, data_type: 'text' })
|
||||
end
|
||||
unless StatisticField.find_by(key: 'themes', statistic_index_id: 6)
|
||||
StatisticField.create!({ key: 'themes', label: I18n.t('statistics.themes'), statistic_index_id: 6, data_type: 'list' })
|
||||
StatisticField.create!({ key: 'themes', label_i18n_path: 'statistics.themes', statistic_index_id: 6, data_type: 'list' })
|
||||
end
|
||||
unless StatisticField.find_by(key: 'components', statistic_index_id: 6)
|
||||
StatisticField.create!({ key: 'components', label: I18n.t('statistics.components'), statistic_index_id: 6, data_type: 'list' })
|
||||
StatisticField.create!({ key: 'components', label_i18n_path: 'statistics.components', statistic_index_id: 6, data_type: 'list' })
|
||||
end
|
||||
unless StatisticField.find_by(key: 'machines', statistic_index_id: 6)
|
||||
StatisticField.create!({ key: 'machines', label: I18n.t('statistics.machines'), statistic_index_id: 6, data_type: 'list' })
|
||||
StatisticField.create!({ key: 'machines', label_i18n_path: 'statistics.machines', statistic_index_id: 6, data_type: 'list' })
|
||||
end
|
||||
unless StatisticField.find_by(key: 'status', statistic_index_id: 6)
|
||||
StatisticField.create!({ key: 'status', label: I18n.t('statistics.project_status'), statistic_index_id: 6, data_type: 'text' })
|
||||
StatisticField.create!({ key: 'status', label_i18n_path: 'statistics.project_status', statistic_index_id: 6, data_type: 'text' })
|
||||
end
|
||||
unless StatisticField.find_by(key: 'name', statistic_index_id: 6)
|
||||
StatisticField.create!({ key: 'name', label: I18n.t('statistics.project_name'), statistic_index_id: 6, data_type: 'text' })
|
||||
StatisticField.create!({ key: 'name', label_i18n_path: 'statistics.project_name', statistic_index_id: 6, data_type: 'text' })
|
||||
end
|
||||
unless StatisticField.find_by(key: 'projectUserNames', statistic_index_id: 6)
|
||||
StatisticField.create!({ key: 'projectUserNames', label: I18n.t('statistics.project_user_names'), statistic_index_id: 6, data_type: 'list' })
|
||||
StatisticField.create!({ key: 'projectUserNames', label_i18n_path: 'statistics.project_user_names', statistic_index_id: 6, data_type: 'list' })
|
||||
end
|
||||
unless StatisticField.find_by(key: 'name', statistic_index_id: 4)
|
||||
StatisticField.create!({ key: 'name', label: I18n.t('statistics.event_name'), statistic_index_id: 4, data_type: 'text' })
|
||||
StatisticField.create!({ key: 'name', label_i18n_path: 'statistics.event_name', statistic_index_id: 4, data_type: 'text' })
|
||||
end
|
||||
unless StatisticField.find_by(key: 'userId', statistic_index_id: 7)
|
||||
StatisticField.create!({ key: 'userId', label: I18n.t('statistics.user_id'), statistic_index_id: 7, data_type: 'index' })
|
||||
StatisticField.create!({ key: 'userId', label_i18n_path: 'statistics.user_id', statistic_index_id: 7, data_type: 'index' })
|
||||
end
|
||||
unless StatisticField.find_by(key: 'eventTheme', statistic_index_id: 4)
|
||||
StatisticField.create!({ key: 'eventTheme', label: I18n.t('statistics.event_theme'), statistic_index_id: 4, data_type: 'text' })
|
||||
StatisticField.create!({ key: 'eventTheme', label_i18n_path: 'statistics.event_theme', statistic_index_id: 4, data_type: 'text' })
|
||||
end
|
||||
unless StatisticField.find_by(key: 'ageRange', statistic_index_id: 4)
|
||||
StatisticField.create!({ key: 'ageRange', label: I18n.t('statistics.age_range'), statistic_index_id: 4, data_type: 'text' })
|
||||
StatisticField.create!({ key: 'ageRange', label_i18n_path: 'statistics.age_range', statistic_index_id: 4, data_type: 'text' })
|
||||
end
|
||||
unless StatisticField.find_by(key: 'groupName', statistic_index_id: 1)
|
||||
StatisticField.create!({ key: 'groupName', label: I18n.t('statistics.group'), statistic_index_id: 1, data_type: 'text' })
|
||||
StatisticField.create!({ key: 'groupName', label_i18n_path: 'statistics.group', statistic_index_id: 1, data_type: 'text' })
|
||||
end
|
||||
unless StatisticField.find_by(key: 'groupName', statistic_index_id: statistic_index_order.id)
|
||||
StatisticField.create!({ key: 'groupName', label: I18n.t('statistics.group'), statistic_index_id: statistic_index_order.id, data_type: 'text' })
|
||||
StatisticField.create!({ key: 'groupName', label_i18n_path: 'statistics.group', statistic_index_id: statistic_index_order.id, data_type: 'text' })
|
||||
end
|
||||
|
||||
# statistic_types
|
||||
unless StatisticType.find_by(key: 'booking', statistic_index_id: 2)
|
||||
StatisticType.create!({ statistic_index_id: 2, key: 'booking', label: I18n.t('statistics.bookings'), graph: true, simple: true })
|
||||
StatisticType.create!({ statistic_index_id: 2, key: 'booking', label_i18n_path: 'statistics.bookings', graph: true, simple: true })
|
||||
end
|
||||
unless StatisticType.find_by(key: 'hour', statistic_index_id: 2)
|
||||
StatisticType.create!({ statistic_index_id: 2, key: 'hour', label: I18n.t('statistics.hours_number'), graph: true, simple: false })
|
||||
StatisticType.create!({ statistic_index_id: 2, key: 'hour', label_i18n_path: 'statistics.hours_number', graph: true, simple: false })
|
||||
end
|
||||
unless StatisticType.find_by(key: 'booking', statistic_index_id: 3)
|
||||
StatisticType.create!({ statistic_index_id: 3, key: 'booking', label: I18n.t('statistics.bookings'), graph: false, simple: true })
|
||||
StatisticType.create!({ statistic_index_id: 3, key: 'booking', label_i18n_path: 'statistics.bookings', graph: false, simple: true })
|
||||
end
|
||||
unless StatisticType.find_by(key: 'hour', statistic_index_id: 3)
|
||||
StatisticType.create!({ statistic_index_id: 3, key: 'hour', label: I18n.t('statistics.hours_number'), graph: false, simple: false })
|
||||
StatisticType.create!({ statistic_index_id: 3, key: 'hour', label_i18n_path: 'statistics.hours_number', graph: false, simple: false })
|
||||
end
|
||||
unless StatisticType.find_by(key: 'booking', statistic_index_id: 4)
|
||||
StatisticType.create!({ statistic_index_id: 4, key: 'booking', label: I18n.t('statistics.tickets_number'), graph: false, simple: false })
|
||||
StatisticType.create!({ statistic_index_id: 4, key: 'booking', label_i18n_path: 'statistics.tickets_number', graph: false, simple: false })
|
||||
end
|
||||
unless StatisticType.find_by(key: 'hour', statistic_index_id: 4)
|
||||
StatisticType.create!({ statistic_index_id: 4, key: 'hour', label: I18n.t('statistics.hours_number'), graph: false, simple: false })
|
||||
StatisticType.create!({ statistic_index_id: 4, key: 'hour', label_i18n_path: 'statistics.hours_number', graph: false, simple: false })
|
||||
end
|
||||
unless StatisticType.find_by(key: 'member', statistic_index_id: 5)
|
||||
StatisticType.create!({ statistic_index_id: 5, key: 'member', label: I18n.t('statistics.users'), graph: true, simple: true })
|
||||
StatisticType.create!({ statistic_index_id: 5, key: 'member', label_i18n_path: 'statistics.users', graph: true, simple: true })
|
||||
end
|
||||
unless StatisticType.find_by(key: 'project', statistic_index_id: 6)
|
||||
StatisticType.create!({ statistic_index_id: 6, key: 'project', label: I18n.t('statistics.projects'), graph: false, simple: true })
|
||||
StatisticType.create!({ statistic_index_id: 6, key: 'project', label_i18n_path: 'statistics.projects', graph: false, simple: true })
|
||||
end
|
||||
unless StatisticType.find_by(key: 'revenue', statistic_index_id: 7)
|
||||
StatisticType.create!({ statistic_index_id: 7, key: 'revenue', label: I18n.t('statistics.revenue'), graph: false, simple: false })
|
||||
StatisticType.create!({ statistic_index_id: 7, key: 'revenue', label_i18n_path: 'statistics.revenue', graph: false, simple: false })
|
||||
end
|
||||
unless StatisticType.find_by(key: 'booking', statistic_index_id: statistic_index_space.id)
|
||||
StatisticType.create!({ statistic_index_id: statistic_index_space.id, key: 'booking', label: I18n.t('statistics.bookings'),
|
||||
StatisticType.create!({ statistic_index_id: statistic_index_space.id, key: 'booking', label_i18n_path: 'statistics.bookings',
|
||||
graph: true, simple: true })
|
||||
end
|
||||
unless StatisticType.find_by(key: 'hour', statistic_index_id: statistic_index_space.id)
|
||||
StatisticType.create!({ statistic_index_id: statistic_index_space.id, key: 'hour', label: I18n.t('statistics.hours_number'),
|
||||
StatisticType.create!({ statistic_index_id: statistic_index_space.id, key: 'hour', label_i18n_path: 'statistics.hours_number',
|
||||
graph: true, simple: false })
|
||||
end
|
||||
unless StatisticType.find_by(key: 'store', statistic_index_id: statistic_index_order.id)
|
||||
StatisticType.create!({ statistic_index_id: statistic_index_order.id, key: 'store', label: I18n.t('statistics.store'),
|
||||
StatisticType.create!({ statistic_index_id: statistic_index_order.id, key: 'store', label_i18n_path: 'statistics.store',
|
||||
graph: true, simple: true })
|
||||
end
|
||||
Plan.find_each do |plan|
|
||||
@ -155,19 +155,19 @@ end
|
||||
|
||||
# statistic_sub_types
|
||||
unless StatisticSubType.find_by(key: 'created')
|
||||
StatisticSubType.create!({ key: 'created', label: I18n.t('statistics.account_creation'),
|
||||
StatisticSubType.create!({ key: 'created', label_i18n_path: 'statistics.account_creation',
|
||||
statistic_types: StatisticIndex.find_by(es_type_key: 'account').statistic_types })
|
||||
end
|
||||
unless StatisticSubType.find_by(key: 'published')
|
||||
StatisticSubType.create!({ key: 'published', label: I18n.t('statistics.project_publication'),
|
||||
StatisticSubType.create!({ key: 'published', label_i18n_path: 'statistics.project_publication',
|
||||
statistic_types: StatisticIndex.find_by(es_type_key: 'project').statistic_types })
|
||||
end
|
||||
unless StatisticSubType.find_by(key: 'paid-processed')
|
||||
StatisticSubType.create!({ key: 'paid-processed', label: I18n.t('statistics.paid-processed'),
|
||||
StatisticSubType.create!({ key: 'paid-processed', label_i18n_path: 'statistics.paid-rocessed',
|
||||
statistic_types: statistic_index_order.statistic_types })
|
||||
end
|
||||
unless StatisticSubType.find_by(key: 'aborted')
|
||||
StatisticSubType.create!({ key: 'aborted', label: I18n.t('statistics.aborted'), statistic_types: statistic_index_order.statistic_types })
|
||||
StatisticSubType.create!({ key: 'aborted', label_i18n_path: 'statistics.aborted', statistic_types: statistic_index_order.statistic_types })
|
||||
end
|
||||
Plan.find_each do |plan|
|
||||
type = plan.find_statistic_type
|
||||
|
@ -108,8 +108,8 @@ SET default_tablespace = '';
|
||||
|
||||
CREATE TABLE public.abuses (
|
||||
id integer NOT NULL,
|
||||
signaled_id integer,
|
||||
signaled_type character varying,
|
||||
signaled_id integer,
|
||||
first_name character varying,
|
||||
last_name character varying,
|
||||
email character varying,
|
||||
@ -229,8 +229,8 @@ CREATE TABLE public.addresses (
|
||||
locality character varying,
|
||||
country character varying,
|
||||
postal_code character varying,
|
||||
placeable_id integer,
|
||||
placeable_type character varying,
|
||||
placeable_id integer,
|
||||
created_at timestamp without time zone,
|
||||
updated_at timestamp without time zone
|
||||
);
|
||||
@ -339,8 +339,8 @@ CREATE TABLE public.ar_internal_metadata (
|
||||
|
||||
CREATE TABLE public.assets (
|
||||
id integer NOT NULL,
|
||||
viewable_id integer,
|
||||
viewable_type character varying,
|
||||
viewable_id integer,
|
||||
attachment character varying,
|
||||
type character varying,
|
||||
created_at timestamp without time zone,
|
||||
@ -1066,8 +1066,8 @@ ALTER SEQUENCE public.coupons_id_seq OWNED BY public.coupons.id;
|
||||
|
||||
CREATE TABLE public.credits (
|
||||
id integer NOT NULL,
|
||||
creditable_id integer,
|
||||
creditable_type character varying,
|
||||
creditable_id integer,
|
||||
plan_id integer,
|
||||
hours integer,
|
||||
created_at timestamp without time zone,
|
||||
@ -1868,15 +1868,15 @@ ALTER SEQUENCE public.notification_types_id_seq OWNED BY public.notification_typ
|
||||
CREATE TABLE public.notifications (
|
||||
id integer NOT NULL,
|
||||
receiver_id integer,
|
||||
attached_object_id integer,
|
||||
attached_object_type character varying,
|
||||
attached_object_id integer,
|
||||
notification_type_id integer,
|
||||
is_read boolean DEFAULT false,
|
||||
created_at timestamp without time zone,
|
||||
updated_at timestamp without time zone,
|
||||
receiver_type character varying,
|
||||
is_send boolean DEFAULT false,
|
||||
meta_data jsonb DEFAULT '{}'::jsonb
|
||||
meta_data jsonb DEFAULT '"{}"'::jsonb
|
||||
);
|
||||
|
||||
|
||||
@ -2605,8 +2605,8 @@ CREATE TABLE public.prices (
|
||||
id integer NOT NULL,
|
||||
group_id integer,
|
||||
plan_id integer,
|
||||
priceable_id integer,
|
||||
priceable_type character varying,
|
||||
priceable_id integer,
|
||||
amount integer,
|
||||
created_at timestamp without time zone NOT NULL,
|
||||
updated_at timestamp without time zone NOT NULL,
|
||||
@ -3164,8 +3164,8 @@ CREATE TABLE public.reservations (
|
||||
message text,
|
||||
created_at timestamp without time zone,
|
||||
updated_at timestamp without time zone,
|
||||
reservable_id integer,
|
||||
reservable_type character varying,
|
||||
reservable_id integer,
|
||||
nb_reserve_places integer,
|
||||
statistic_profile_id integer,
|
||||
reservation_context_id bigint
|
||||
@ -3198,8 +3198,8 @@ ALTER SEQUENCE public.reservations_id_seq OWNED BY public.reservations.id;
|
||||
CREATE TABLE public.roles (
|
||||
id integer NOT NULL,
|
||||
name character varying,
|
||||
resource_id integer,
|
||||
resource_type character varying,
|
||||
resource_id integer,
|
||||
created_at timestamp without time zone,
|
||||
updated_at timestamp without time zone
|
||||
);
|
||||
@ -3451,7 +3451,8 @@ CREATE TABLE public.statistic_fields (
|
||||
label character varying,
|
||||
created_at timestamp without time zone,
|
||||
updated_at timestamp without time zone,
|
||||
data_type character varying
|
||||
data_type character varying,
|
||||
label_i18n_path character varying
|
||||
);
|
||||
|
||||
|
||||
@ -3518,7 +3519,8 @@ CREATE TABLE public.statistic_indices (
|
||||
created_at timestamp without time zone,
|
||||
updated_at timestamp without time zone,
|
||||
"table" boolean DEFAULT true,
|
||||
ca boolean DEFAULT true
|
||||
ca boolean DEFAULT true,
|
||||
label_i18n_path character varying
|
||||
);
|
||||
|
||||
|
||||
@ -3651,7 +3653,8 @@ CREATE TABLE public.statistic_sub_types (
|
||||
key character varying,
|
||||
label character varying,
|
||||
created_at timestamp without time zone,
|
||||
updated_at timestamp without time zone
|
||||
updated_at timestamp without time zone,
|
||||
label_i18n_path character varying
|
||||
);
|
||||
|
||||
|
||||
@ -3718,7 +3721,8 @@ CREATE TABLE public.statistic_types (
|
||||
graph boolean,
|
||||
created_at timestamp without time zone,
|
||||
updated_at timestamp without time zone,
|
||||
simple boolean
|
||||
simple boolean,
|
||||
label_i18n_path character varying
|
||||
);
|
||||
|
||||
|
||||
@ -6019,6 +6023,14 @@ ALTER TABLE ONLY public.roles
|
||||
ADD CONSTRAINT roles_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public.schema_migrations
|
||||
ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version);
|
||||
|
||||
|
||||
--
|
||||
-- Name: settings settings_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
@ -7783,13 +7795,6 @@ CREATE INDEX proof_of_identity_type_id_and_proof_of_identity_refusal_id ON publi
|
||||
CREATE UNIQUE INDEX unique_not_null_external_id ON public.invoicing_profiles USING btree (external_id) WHERE (external_id IS NOT NULL);
|
||||
|
||||
|
||||
--
|
||||
-- Name: unique_schema_migrations; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE UNIQUE INDEX unique_schema_migrations ON public.schema_migrations USING btree (version);
|
||||
|
||||
|
||||
--
|
||||
-- Name: accounting_periods accounting_periods_del_protect; Type: RULE; Schema: public; Owner: -
|
||||
--
|
||||
@ -8854,7 +8859,6 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||
('20140605125131'),
|
||||
('20140605142133'),
|
||||
('20140605151442'),
|
||||
('20140606133116'),
|
||||
('20140609092700'),
|
||||
('20140609092827'),
|
||||
('20140610153123'),
|
||||
@ -8923,14 +8927,12 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||
('20150507075620'),
|
||||
('20150512123546'),
|
||||
('20150520132030'),
|
||||
('20150520133409'),
|
||||
('20150526130729'),
|
||||
('20150527153312'),
|
||||
('20150529113555'),
|
||||
('20150601125944'),
|
||||
('20150603104502'),
|
||||
('20150603104658'),
|
||||
('20150603133050'),
|
||||
('20150604081757'),
|
||||
('20150604131525'),
|
||||
('20150608142234'),
|
||||
@ -9012,7 +9014,6 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||
('20160905142700'),
|
||||
('20160906094739'),
|
||||
('20160906094847'),
|
||||
('20160906145713'),
|
||||
('20160915105234'),
|
||||
('20161123104604'),
|
||||
('20170109085345'),
|
||||
@ -9201,6 +9202,7 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||
('20230828073428'),
|
||||
('20230831103208'),
|
||||
('20230901090637'),
|
||||
('20230907124230');
|
||||
('20230907124230'),
|
||||
('20231103093436');
|
||||
|
||||
|
||||
|
@ -52,7 +52,7 @@ class FileSizeValidator < ActiveModel::EachValidator
|
||||
default_message = options[MESSAGES[key]]
|
||||
errors_options[:message] ||= default_message if default_message
|
||||
|
||||
record.errors.add(attribute, MESSAGES[key], errors_options)
|
||||
record.errors.add(attribute, MESSAGES[key], **errors_options)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1,14 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# module definition
|
||||
module FabManager::Middleware; end
|
||||
|
||||
# Provides localization in workers
|
||||
class FabManager::Middleware::ServerLocale
|
||||
def call(_worker_class, job, _queue)
|
||||
locale = job['locale'] || Rails.application.secrets.rails_locale
|
||||
I18n.with_locale(locale) do
|
||||
yield
|
||||
end
|
||||
end
|
||||
end
|
@ -19,11 +19,9 @@ namespace :fablab do
|
||||
|
||||
desc 'assign all footprints to existing Invoice records'
|
||||
task invoices: :environment do
|
||||
if Invoice.where.not(footprint: nil).count.positive?
|
||||
print 'WARNING: Footprints were already generated. Regenerate? (y/n) '
|
||||
confirm = $stdin.gets.chomp
|
||||
next unless confirm == 'y'
|
||||
end
|
||||
print 'Are you sure you want to regenerate footprints? (y/n) '
|
||||
confirm = $stdin.gets.chomp
|
||||
next unless confirm == 'y'
|
||||
chain_invoices
|
||||
end
|
||||
|
||||
@ -40,11 +38,9 @@ namespace :fablab do
|
||||
|
||||
desc 'assign all footprints to existing InvoiceItem records'
|
||||
task invoices_items: :environment do
|
||||
if InvoiceItem.where.not(footprint: nil).count.positive?
|
||||
print 'WARNING: Footprints were already generated. Regenerate? (y/n) '
|
||||
confirm = $stdin.gets.chomp
|
||||
next unless confirm == 'y'
|
||||
end
|
||||
print 'Are you sure you want to regenerate footprints? (y/n) '
|
||||
confirm = $stdin.gets.chomp
|
||||
next unless confirm == 'y'
|
||||
chain_invoice_items
|
||||
end
|
||||
|
||||
@ -61,11 +57,9 @@ namespace :fablab do
|
||||
|
||||
desc 'assign all footprints to existing HistoryValue records'
|
||||
task history_values: :environment do
|
||||
if HistoryValue.where.not(footprint: nil).count.positive?
|
||||
print 'WARNING: Footprints were already generated. Regenerate? (y/n) '
|
||||
confirm = $stdin.gets.chomp
|
||||
next unless confirm == 'y'
|
||||
end
|
||||
print 'Are you sure you want to regenerate footprints? (y/n) '
|
||||
confirm = $stdin.gets.chomp
|
||||
next unless confirm == 'y'
|
||||
chain_history_values
|
||||
end
|
||||
|
||||
@ -75,11 +69,9 @@ namespace :fablab do
|
||||
|
||||
desc 'assign all footprints to existing PaymentSchedule records'
|
||||
task payment_schedule: :environment do
|
||||
if PaymentSchedule.where.not(footprint: nil).count.positive?
|
||||
print 'WARNING: Footprints were already generated. Regenerate? (y/n) '
|
||||
confirm = $stdin.gets.chomp
|
||||
next unless confirm == 'y'
|
||||
end
|
||||
print 'Are you sure you want to regenerate footprints? (y/n) '
|
||||
confirm = $stdin.gets.chomp
|
||||
next unless confirm == 'y'
|
||||
chain_payment_schedules
|
||||
end
|
||||
|
||||
@ -96,11 +88,9 @@ namespace :fablab do
|
||||
|
||||
desc 'assign all footprints to existing PaymentScheduleItem records'
|
||||
task payment_schedule_item: :environment do
|
||||
if PaymentScheduleItem.where.not(footprint: nil).count.positive?
|
||||
print 'WARNING: Footprints were already generated. Regenerate? (y/n) '
|
||||
confirm = $stdin.gets.chomp
|
||||
next unless confirm == 'y'
|
||||
end
|
||||
print 'Are you sure you want to regenerate footprints? (y/n) '
|
||||
confirm = $stdin.gets.chomp
|
||||
next unless confirm == 'y'
|
||||
chain_payment_schedules_items
|
||||
end
|
||||
|
||||
@ -117,11 +107,9 @@ namespace :fablab do
|
||||
|
||||
desc 'assign all footprints to existing PaymentScheduleObject records'
|
||||
task payment_schedule_object: :environment do
|
||||
if PaymentScheduleObject.where.not(footprint: nil).count.positive?
|
||||
print 'WARNING: Footprints were already generated. Regenerate? (y/n) '
|
||||
confirm = $stdin.gets.chomp
|
||||
next unless confirm == 'y'
|
||||
end
|
||||
print 'Are you sure you want to regenerate footprints? (y/n) '
|
||||
confirm = $stdin.gets.chomp
|
||||
next unless confirm == 'y'
|
||||
chain_payment_schedules_objects
|
||||
end
|
||||
|
||||
|
@ -14,6 +14,15 @@ namespace :fablab do
|
||||
puts '-> Done'
|
||||
end
|
||||
|
||||
desc 'Regenerate the invoices (invoices & avoirs) PDF by ids'
|
||||
# example: rails fablab:maintenance:regenerate_invoices_by_ids[1,2,3,4]
|
||||
task regenerate_invoices_by_ids: :environment do |_task, args|
|
||||
puts "-> Start regenerate the invoices PDF"
|
||||
invoices = Invoice.where(id: args.extras)
|
||||
invoices.each(&:regenerate_invoice_pdf)
|
||||
puts '-> Done'
|
||||
end
|
||||
|
||||
task :regenerate_schedules, %i[year month end] => :environment do |_task, args|
|
||||
start_date, end_date = dates_from_args(args)
|
||||
puts "-> Start regenerate the payment schedules PDF between #{I18n.l start_date, format: :long} and " \
|
||||
@ -162,5 +171,22 @@ namespace :fablab do
|
||||
abuse.destroy if abuse.signaled.nil?
|
||||
end
|
||||
end
|
||||
|
||||
desc "Removes all reservations, invoice, invoice_items, chained_elements (of invoices)"
|
||||
task delete_all_reservations_and_invoices: :environment do
|
||||
print 'Are you sure you want to erase all reservations and invoices ? (y/n) '
|
||||
confirm = $stdin.gets.chomp
|
||||
next unless confirm == 'y'
|
||||
|
||||
ChainedElement.where(element_type: %w[Invoice InvoiceItem PaymentSchedule PaymentScheduleItem PaymentScheduleObject]).delete_all
|
||||
Order.destroy_all
|
||||
PaymentSchedule.destroy_all
|
||||
PaymentScheduleItem.destroy_all
|
||||
PaymentScheduleObject.destroy_all
|
||||
Invoice.destroy_all
|
||||
Reservation.destroy_all
|
||||
|
||||
FileUtils.rm_rf Dir.glob(Rails.root.join("invoices/*"))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "fab-manager",
|
||||
"version": "6.2.0",
|
||||
"version": "6.3.0",
|
||||
"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",
|
||||
|
Loading…
x
Reference in New Issue
Block a user