Add a way to check for notifications on dossiers terminé
This commit is contained in:
parent
4f8a19718f
commit
55f15b2354
1 changed files with 18 additions and 4 deletions
|
@ -101,14 +101,28 @@ class Gestionnaire < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def notifications_for_procedure(procedure)
|
def notifications_for_procedure(procedure, state = :en_cours)
|
||||||
dossiers = procedure.dossiers.en_cours.followed_by(self)
|
dossiers = case state
|
||||||
|
when :termine
|
||||||
|
procedure.dossiers.termine
|
||||||
|
when :not_archived
|
||||||
|
procedure.dossiers.not_archived
|
||||||
|
else
|
||||||
|
procedure.dossiers.en_cours
|
||||||
|
end.followed_by(self)
|
||||||
|
|
||||||
dossiers_id_with_notifications(dossiers)
|
dossiers_id_with_notifications(dossiers)
|
||||||
end
|
end
|
||||||
|
|
||||||
def notifications_per_procedure
|
def notifications_per_procedure(state = :en_cours)
|
||||||
dossiers = Dossier.en_cours.followed_by(self)
|
dossiers = case state
|
||||||
|
when :termine
|
||||||
|
Dossier.termine
|
||||||
|
when :not_archived
|
||||||
|
Dossier.not_archived
|
||||||
|
else
|
||||||
|
Dossier.en_cours
|
||||||
|
end.followed_by(self)
|
||||||
|
|
||||||
Dossier.where(id: dossiers_id_with_notifications(dossiers)).group(:procedure_id).count
|
Dossier.where(id: dossiers_id_with_notifications(dossiers)).group(:procedure_id).count
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue