Use scopes when possible

This commit is contained in:
gregoirenovel 2018-08-28 14:50:44 +02:00
parent 47962ef795
commit e60aa0c37b
4 changed files with 5 additions and 5 deletions

View file

@ -7,7 +7,7 @@ class StatsController < ApplicationController
def index def index
procedures = Procedure.publiees_ou_archivees procedures = Procedure.publiees_ou_archivees
dossiers = Dossier.where.not(:state => Dossier.states.fetch(:brouillon)) dossiers = Dossier.state_not_brouillon
@procedures_numbers = procedures_numbers(procedures) @procedures_numbers = procedures_numbers(procedures)
@dossiers_numbers = dossiers_numbers(dossiers) @dossiers_numbers = dossiers_numbers(dossiers)

View file

@ -124,7 +124,7 @@
partenaires partenaires
%li.number %li.number
.number-value .number-value
= number_with_delimiter(Dossier.where.not(:state => Dossier.states.fetch(:brouillon)).count, :locale => :fr) = number_with_delimiter(Dossier.state_not_brouillon.count, :locale => :fr)
.number-label< .number-label<
dossiers dossiers
%br<> %br<>

View file

@ -50,7 +50,7 @@
partenaires partenaires
%li.number %li.number
.number-value .number-value
= number_with_delimiter(Dossier.where.not(:state => Dossier.states.fetch(:brouillon)).count, :locale => :fr) = number_with_delimiter(Dossier.state_not_brouillon.count, :locale => :fr)
.number-label< .number-label<
dossiers dossiers
%br<> %br<>

View file

@ -170,7 +170,7 @@ describe StatsController, type: :controller do
} }
end end
let (:association) { Dossier.where.not(:state => Dossier.states.fetch(:brouillon)) } let (:association) { Dossier.state_not_brouillon }
subject { StatsController.new.send(:dossier_instruction_mean_time, association) } subject { StatsController.new.send(:dossier_instruction_mean_time, association) }
@ -222,7 +222,7 @@ describe StatsController, type: :controller do
} }
end end
let (:association) { Dossier.where.not(:state => Dossier.states.fetch(:brouillon)) } let (:association) { Dossier.state_not_brouillon }
subject { StatsController.new.send(:dossier_filling_mean_time, association) } subject { StatsController.new.send(:dossier_filling_mean_time, association) }