Merge pull request #5714 from betagouv/fix-counters

Correction du compteur de dossiers à suivre
This commit is contained in:
Keirua 2020-11-04 17:13:01 +01:00 committed by GitHub
commit 29cfdfbe91
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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