1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-18 07:52:23 +01:00

[bug] no statistics for subscriptions (#196)

+ [bug] issing translation for subscriptions statistics > duration
This commit is contained in:
Sylvain 2020-04-01 17:25:55 +02:00
parent 40903721fa
commit 3917d6042c
7 changed files with 18 additions and 4 deletions

View File

@ -11,17 +11,19 @@
- Renamed production documentation - Renamed production documentation
- Syntax improvements in scss files - Syntax improvements in scss files
- Fix a bug: crediting a wallet w/ refund invoice prevent statistics generation (#196) - Fix a bug: crediting a wallet w/ refund invoice prevent statistics generation (#196)
- Fix a bug: no statistics for subscriptions (#196)
- Fix a bug: invalid translation keys in closing accounting period interface - Fix a bug: invalid translation keys in closing accounting period interface
- Fix a bug: since PostgreSQL release 9.6.17, the new installations will fail to start complaining for missing password (#194) - Fix a bug: since PostgreSQL release 9.6.17, the new installations will fail to start complaining for missing password (#194)
- Fix a bug: missing translations for some error messages - Fix a bug: missing translations for some error messages
- Fix a bug: invalid footprints in invoices fixtures - Fix a bug: invalid footprints in invoices fixtures
- Fix a bug: unable to export accounting data to ACD - Fix a bug: unable to export accounting data to ACD
- Fix a bug: report error on invalid encoding in members import - Fix a bug: report error on invalid encoding in members import
- Fix a bug: missing translation for subscriptions statistics > duration
- Fix a security issue: updated mkdirp to fix [CVE-2020-7598](https://nvd.nist.gov/vuln/detail/CVE-2020-7598) - Fix a security issue: updated mkdirp to fix [CVE-2020-7598](https://nvd.nist.gov/vuln/detail/CVE-2020-7598)
- Fix a security issue: updated acorn to fix [CVE-2020-7598](https://nvd.nist.gov/vuln/detail/CVE-2020-7598) - Fix a security issue: updated acorn to fix [CVE-2020-7598](https://nvd.nist.gov/vuln/detail/CVE-2020-7598)
- Fix a security issue: updated actionview to fix [CVE-2020-5267](https://nvd.nist.gov/vuln/detail/CVE-2020-5267) - Fix a security issue: updated actionview to fix [CVE-2020-5267](https://nvd.nist.gov/vuln/detail/CVE-2020-5267)
- [TODO DEPLOY] `rails fablab:fix:avoirs_wallet_transaction` - [TODO DEPLOY] `rails fablab:fix:avoirs_wallet_transaction`
- [TODO DEPLOY] `rails fablab:es:generate_stats[289]` only if you had missing statistics since some date ago. You can replace 289 by the difference of days between the day you run this task and the last day you had statistics - [TODO DEPLOY] `rails fablab:es:generate_stats[289]` only if you had missing statistics since some date ago (here 289 days)
## v4.3.2 2020 March 11 ## v4.3.2 2020 March 11

View File

@ -84,12 +84,12 @@ class Plan < ApplicationRecord
# must be publicly accessible for the migration # must be publicly accessible for the migration
def create_statistic_type def create_statistic_type
stat_index = StatisticIndex.where(es_type_key: 'subscription') stat_index = StatisticIndex.where(es_type_key: 'subscription')
type = StatisticType.find_by(statistic_index_id: stat_index.first.id, key: duration.to_i) type = find_statistic_type
if type.nil? if type.nil?
type = StatisticType.create!( type = StatisticType.create!(
statistic_index_id: stat_index.first.id, statistic_index_id: stat_index.first.id,
key: duration.to_i, key: duration.to_i,
label: "Durée : #{human_readable_duration}", label: "#{I18n.t('statistics.duration')} : #{human_readable_duration}",
graph: true, graph: true,
simple: true simple: true
) )
@ -98,6 +98,14 @@ class Plan < ApplicationRecord
create_statistic_association(type, subtype) create_statistic_association(type, subtype)
end 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)
return type if type
StatisticType.where(statistic_index_id: stat_index.first.id).where('label LIKE ?', "%#{human_readable_duration}%").first
end
private private
def create_statistic_subtype def create_statistic_subtype

View File

@ -147,7 +147,7 @@ class StatisticService
plan_interval_count: p.interval_count, plan_interval_count: p.interval_count,
plan_group_name: p.group.name, plan_group_name: p.group.name,
slug: p.slug, slug: p.slug,
duration: p.duration.to_i, duration: p.find_statistic_type.key,
subscription_id: sub.id, subscription_id: sub.id,
invoice_item_id: i.id, invoice_item_id: i.id,
ca: ca ca: ca

View File

@ -356,6 +356,7 @@ en:
revenue: "Revenue" revenue: "Revenue"
account_creation: "Account creation" account_creation: "Account creation"
project_publication: "Project publication" project_publication: "Project publication"
duration: "Duration"
#statistics exports to the excel file format #statistics exports to the excel file format
export: export:
entries: "Entries" entries: "Entries"

View File

@ -356,6 +356,7 @@ es:
revenue: "Ingresos" revenue: "Ingresos"
account_creation: "Creación de cuenta" account_creation: "Creación de cuenta"
project_publication: "Publicación de proyectos" project_publication: "Publicación de proyectos"
duration: "Duración"
#statistics exports to the excel file format #statistics exports to the excel file format
export: export:
entries: "Entradas" entries: "Entradas"

View File

@ -356,6 +356,7 @@ fr:
revenue: "Chiffre d'affaires" revenue: "Chiffre d'affaires"
account_creation: "Création de compte" account_creation: "Création de compte"
project_publication: "Publication de projet" project_publication: "Publication de projet"
duration: "Durée"
#statistics exports to the excel file format #statistics exports to the excel file format
export: export:
entries: "Entrées" entries: "Entrées"

View File

@ -356,6 +356,7 @@ pt:
revenue: "Receita" revenue: "Receita"
account_creation: "Criação de conta" account_creation: "Criação de conta"
project_publication: "Publicação de projeto" project_publication: "Publicação de projeto"
duration: "Duração"
#statistics exports to the excel file format #statistics exports to the excel file format
export: export:
entries: "Entradas" entries: "Entradas"