commit
331159b767
1 changed files with 2 additions and 1 deletions
|
@ -633,7 +633,7 @@ class Procedure < ApplicationRecord
|
||||||
def dossiers_count_for_instructeur(instructeur)
|
def dossiers_count_for_instructeur(instructeur)
|
||||||
query = <<-EOF
|
query = <<-EOF
|
||||||
SELECT
|
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 ('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" in ('accepte', 'refuse', 'sans_suite') and not "dossiers"."archived" ) AS termines,
|
||||||
COUNT(*) FILTER ( WHERE "dossiers"."state" != 'brouillon' and not "dossiers"."archived" ) AS total,
|
COUNT(*) FILTER ( WHERE "dossiers"."state" != 'brouillon' and not "dossiers"."archived" ) AS total,
|
||||||
|
@ -652,6 +652,7 @@ class Procedure < ApplicationRecord
|
||||||
LEFT OUTER JOIN
|
LEFT OUTER JOIN
|
||||||
"follows"
|
"follows"
|
||||||
ON "follows"."dossier_id" = "dossiers"."id"
|
ON "follows"."dossier_id" = "dossiers"."id"
|
||||||
|
AND "follows"."unfollowed_at" IS NULL
|
||||||
WHERE
|
WHERE
|
||||||
"dossiers"."hidden_at" IS NULL
|
"dossiers"."hidden_at" IS NULL
|
||||||
AND "assign_tos"."instructeur_id" = :instructeur_id
|
AND "assign_tos"."instructeur_id" = :instructeur_id
|
||||||
|
|
Loading…
Reference in a new issue