diff --git a/app/controllers/root_controller.rb b/app/controllers/root_controller.rb index a6d3b385b..9c4341420 100644 --- a/app/controllers/root_controller.rb +++ b/app/controllers/root_controller.rb @@ -12,6 +12,8 @@ class RootController < ApplicationController return redirect_to manager_root_path end + @stat = Stat.first + render 'landing' end diff --git a/app/models/stat.rb b/app/models/stat.rb index b38645007..50d68a105 100644 --- a/app/models/stat.rb +++ b/app/models/stat.rb @@ -3,6 +3,7 @@ # Table name: stats # # id :bigint not null, primary key +# administrations_partenaires :bigint default(0) # dossiers_brouillon :bigint default(0) # dossiers_cumulative :jsonb not null # dossiers_depose_avant_30_jours :bigint default(0) @@ -30,7 +31,8 @@ class Stat < ApplicationRecord dossiers_not_brouillon: states['not_brouillon'], dossiers_termines: states['termines'], dossiers_cumulative: cumulative_hash(Dossier.state_not_brouillon, :en_construction_at), - dossiers_in_the_last_4_months: last_four_months_hash(Dossier.state_not_brouillon, :en_construction_at) + dossiers_in_the_last_4_months: last_four_months_hash(Dossier.state_not_brouillon, :en_construction_at), + administrations_partenaires: AdministrateursProcedure.joins(:procedure).merge(Procedure.publiees_ou_closes).select('distinct administrateur_id').count ) end diff --git a/app/views/root/landing.html.haml b/app/views/root/landing.html.haml index d0636dc25..85568cee2 100644 --- a/app/views/root/landing.html.haml +++ b/app/views/root/landing.html.haml @@ -43,14 +43,14 @@ %ul.numbers %li.number .number-value - = number_with_delimiter(AdministrateursProcedure.joins(:procedure).merge(Procedure.publiees_ou_closes).select('distinct administrateur_id').count, :locale => :fr) + = number_with_delimiter(@stat&.administrations_partenaires, :locale => :fr) .number-label< administrations %br<> partenaires %li.number .number-value - = number_with_delimiter(Dossier.state_not_brouillon.count, :locale => :fr) + = number_with_delimiter(@stat&.dossiers_not_brouillon, :locale => :fr) .number-label< dossiers %br<> diff --git a/db/migrate/20201002124154_create_stats.rb b/db/migrate/20201002124154_create_stats.rb index 593bcef83..571de3423 100644 --- a/db/migrate/20201002124154_create_stats.rb +++ b/db/migrate/20201002124154_create_stats.rb @@ -8,6 +8,7 @@ class CreateStats < ActiveRecord::Migration[6.0] t.bigint :dossiers_termines, default: 0 t.bigint :dossiers_depose_avant_30_jours, default: 0 t.bigint :dossiers_deposes_entre_60_et_30_jours, default: 0 + t.bigint :administrations_partenaires, default: 0 t.jsonb :dossiers_cumulative, null: false, default: '{}' t.jsonb :dossiers_in_the_last_4_months, null: false, default: '{}' diff --git a/db/schema.rb b/db/schema.rb index aa47200d6..b201463e5 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -594,6 +594,7 @@ ActiveRecord::Schema.define(version: 2020_10_02_124154) do t.bigint "dossiers_termines", default: 0 t.bigint "dossiers_depose_avant_30_jours", default: 0 t.bigint "dossiers_deposes_entre_60_et_30_jours", default: 0 + t.bigint "administrations_partenaires", default: 0 t.jsonb "dossiers_cumulative", default: "{}", null: false t.jsonb "dossiers_in_the_last_4_months", default: "{}", null: false t.datetime "created_at", precision: 6, null: false