[Fix #285] Gestionnaire.dossiers_follow -> followed_dossiers

This commit is contained in:
gregoirenovel 2017-05-12 17:58:25 +02:00
parent f67aa63766
commit a58a8684d9
4 changed files with 7 additions and 7 deletions

View file

@ -18,7 +18,7 @@ class DossiersListFacades
end end
def total_dossier_follow def total_dossier_follow
@current_devise_profil.dossiers_follow.count @current_devise_profil.followed_dossiers.count
end end
def total_new_dossier def total_new_dossier

View file

@ -9,7 +9,7 @@ class Gestionnaire < ActiveRecord::Base
has_many :assign_to, dependent: :destroy has_many :assign_to, dependent: :destroy
has_many :procedures, through: :assign_to has_many :procedures, through: :assign_to
has_many :dossiers, -> { where.not(state: :draft) }, through: :procedures has_many :dossiers, -> { where.not(state: :draft) }, through: :procedures
has_many :dossiers_follow, through: :follows, source: :dossier has_many :followed_dossiers, through: :follows, source: :dossier
has_many :follows has_many :follows
has_many :preference_list_dossiers has_many :preference_list_dossiers
@ -72,10 +72,10 @@ class Gestionnaire < ActiveRecord::Base
end end
def notifications_for procedure def notifications_for procedure
procedure_ids = dossiers_follow.pluck(:procedure_id) procedure_ids = followed_dossiers.pluck(:procedure_id)
if procedure_ids.include?(procedure.id) if procedure_ids.include?(procedure.id)
return dossiers_follow.where(procedure_id: procedure.id) return followed_dossiers.where(procedure_id: procedure.id)
.inject(0) do |acc, dossier| .inject(0) do |acc, dossier|
acc += dossier.notifications.where(already_read: false).count acc += dossier.notifications.where(already_read: false).count
end end
@ -84,7 +84,7 @@ class Gestionnaire < ActiveRecord::Base
end end
def dossiers_with_notifications_count_for_procedure(procedure) def dossiers_with_notifications_count_for_procedure(procedure)
followed_dossiers_id = dossiers_follow.where(procedure: procedure).pluck(:id) followed_dossiers_id = followed_dossiers.where(procedure: procedure).pluck(:id)
Notification.unread.where(dossier_id: followed_dossiers_id).select(:dossier_id).distinct(:dossier_id).count Notification.unread.where(dossier_id: followed_dossiers_id).select(:dossier_id).distinct(:dossier_id).count
end end

View file

@ -25,7 +25,7 @@ class DossiersListGestionnaireService
end end
def suivi def suivi
@suivi ||= @current_devise_profil.dossiers_follow.merge(dossiers_to_display) @suivi ||= @current_devise_profil.followed_dossiers.merge(dossiers_to_display)
end end
def nouveaux def nouveaux

View file

@ -1,6 +1,6 @@
#first-block #first-block
.dossiers-en-cours .dossiers-en-cours
.count= current_gestionnaire.dossiers_follow.count .count= current_gestionnaire.followed_dossiers.count
.text SUIVIS .text SUIVIS
.nouveaux-dossiers .nouveaux-dossiers
.count= current_gestionnaire.dossiers.nouveaux.count .count= current_gestionnaire.dossiers.nouveaux.count