From 30dfe7fbd04364aa286a126e0d8bf978190a168d Mon Sep 17 00:00:00 2001 From: clemkeirua Date: Wed, 4 Nov 2020 09:53:22 +0100 Subject: [PATCH] fix a_suivre --- app/models/procedure.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/procedure.rb b/app/models/procedure.rb index 11b87db3f..1f48231c8 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -633,7 +633,7 @@ class Procedure < ApplicationRecord def dossiers_count_for_instructeur(instructeur) query = <<-EOF SELECT - COUNT(*) FILTER ( WHERE "dossiers"."state" in ('en_construction', 'en_instruction') and (("follows"."id" IS NULL) or ("follows"."instructeur_id" = :instructeur_id and "follows"."unfollowed_at" < :now)) and not "dossiers"."archived") AS a_suivre, + COUNT(*) FILTER ( WHERE "dossiers"."state" in ('en_construction', 'en_instruction') and "follows"."id" IS NULL and not "dossiers"."archived") AS a_suivre, COUNT(*) FILTER ( WHERE "dossiers"."state" in ('en_construction', 'en_instruction') and "follows"."instructeur_id" = :instructeur_id and not "dossiers"."archived" and "follows"."unfollowed_at" IS NULL) AS suivis, COUNT(*) FILTER ( WHERE "dossiers"."state" in ('accepte', 'refuse', 'sans_suite') and not "dossiers"."archived" ) AS termines, COUNT(*) FILTER ( WHERE "dossiers"."state" != 'brouillon' and not "dossiers"."archived" ) AS total, @@ -652,6 +652,7 @@ class Procedure < ApplicationRecord LEFT OUTER JOIN "follows" ON "follows"."dossier_id" = "dossiers"."id" + AND "follows"."unfollowed_at" IS NULL WHERE "dossiers"."hidden_at" IS NULL AND "assign_tos"."instructeur_id" = :instructeur_id