diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 43ac679d0..fa88ef74f 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -223,7 +223,7 @@ class Dossier < ApplicationRecord scope :prefilled, -> { where(prefilled: true) } scope :hidden_by_user, -> { where.not(hidden_by_user_at: nil) } scope :hidden_by_administration, -> { where.not(hidden_by_administration_at: nil) } - scope :visible_by_user, -> { where(for_procedure_preview: false).or(where(for_procedure_preview: nil)).where(hidden_by_user_at: nil, editing_fork_origin_id: nil) } + scope :visible_by_user, -> { where(for_procedure_preview: false).where(hidden_by_user_at: nil, editing_fork_origin_id: nil) } scope :visible_by_administration, -> { state_not_brouillon .where(hidden_by_administration_at: nil) diff --git a/app/models/stat.rb b/app/models/stat.rb index 06dec2a55..9ce8744b6 100644 --- a/app/models/stat.rb +++ b/app/models/stat.rb @@ -32,7 +32,7 @@ class Stat < ApplicationRecord COUNT(*) FILTER ( WHERE state != 'brouillon' ) AS "not_brouillon", COUNT(*) FILTER ( WHERE state != 'brouillon' and depose_at BETWEEN :one_month_ago AND :now ) AS "dossiers_depose_avant_30_jours", COUNT(*) FILTER ( WHERE state != 'brouillon' and depose_at BETWEEN :two_months_ago AND :one_month_ago ) AS "dossiers_deposes_entre_60_et_30_jours", - COUNT(*) FILTER ( WHERE state = 'brouillon' AND editing_fork_origin_id IS NULL AND (for_procedure_preview IS NULL OR for_procedure_preview = false)) AS "brouillon", + COUNT(*) FILTER ( WHERE state = 'brouillon' AND editing_fork_origin_id IS NULL AND for_procedure_preview = false) AS "brouillon", COUNT(*) FILTER ( WHERE state = 'en_construction' ) AS "en_construction", COUNT(*) FILTER ( WHERE state = 'en_instruction' ) AS "en_instruction", COUNT(*) FILTER ( WHERE state in ('accepte', 'refuse', 'sans_suite') ) AS "termines" diff --git a/spec/models/stat_spec.rb b/spec/models/stat_spec.rb index 66332df21..049254dda 100644 --- a/spec/models/stat_spec.rb +++ b/spec/models/stat_spec.rb @@ -27,7 +27,6 @@ describe Stat, type: :model do create_list(:dossier, 2, :en_construction, depose_at: 10.days.ago, procedure:) create_list(:dossier, 3, :en_construction, depose_at: 40.days.ago, procedure:) - create_list(:dossier, 3, :brouillon, procedure:, for_procedure_preview: nil) create_list(:dossier, 1, :brouillon, procedure:, for_procedure_preview: false) create_list(:dossier, 6, :en_instruction, procedure:) @@ -48,7 +47,7 @@ describe Stat, type: :model do expect(stats["not_brouillon"]).to eq(18) expect(stats["dossiers_depose_avant_30_jours"]).to eq(2) expect(stats["dossiers_deposes_entre_60_et_30_jours"]).to eq(3) - expect(stats["brouillon"]).to eq(4) + expect(stats["brouillon"]).to eq(1) expect(stats["en_construction"]).to eq(5) expect(stats["en_instruction"]).to eq(6) expect(stats["termines"]).to eq(7)