Use the archived and not_archived Dossier scopes

This commit is contained in:
gregoirenovel 2017-07-10 16:15:09 +02:00
parent f480f26bd4
commit 3a602b05a4
3 changed files with 7 additions and 7 deletions

View file

@ -12,7 +12,7 @@ class AdminProceduresShowFacades
end
def dossiers_for_pie_highchart
dossiers.state_not_brouillon.where.not(archived: true).group(:state).count
dossiers.state_not_brouillon.not_archived.group(:state).count
.reduce({}) do |acc, (key, val)|
translated_key = DossierDecorator.case_state_fr(key)
acc[translated_key].nil? ? acc[translated_key] = val : acc[translated_key] += val
@ -21,11 +21,11 @@ class AdminProceduresShowFacades
end
def dossiers_archived_by_state_total
dossiers.select('state, count(*) as total').where(archived: true).where.not(state: :termine).group(:state).order(:state).decorate
dossiers.select('state, count(*) as total').archived.where.not(state: :termine).group(:state).order(:state).decorate
end
def dossiers_archived_total
dossiers.where(archived: true).where.not(state: :termine).size
dossiers.archived.where.not(state: :termine).size
end
def dossiers_total

View file

@ -14,7 +14,7 @@ class DossiersListFacades
end
def total_dossier
current_devise_profil.dossiers.where(archived: false).count
current_devise_profil.dossiers.not_archived.count
end
def total_dossier_follow
@ -22,11 +22,11 @@ class DossiersListFacades
end
def total_new_dossier
current_devise_profil.dossiers.where(state: :initiated, archived: false).count
current_devise_profil.dossiers.where(state: :initiated).not_archived.count
end
def new_dossier_number procedure_id
current_devise_profil.dossiers.where(state: :initiated, archived: false, procedure_id: procedure_id).count
current_devise_profil.dossiers.where(state: :initiated).not_archived.where(procedure_id: procedure_id).count
end
def gestionnaire_procedures_name_and_id_list

View file

@ -46,7 +46,7 @@ class Search < ActiveRecord::Base
dossier_ids = @gestionnaire.dossiers
.select(:id)
.where(archived: false)
.not_archived
.state_not_brouillon
q = Search