commit
5e8c89684f
5 changed files with 41 additions and 8 deletions
|
@ -102,8 +102,8 @@ type Demarche {
|
||||||
"""
|
"""
|
||||||
since: ISO8601DateTime
|
since: ISO8601DateTime
|
||||||
): DossierConnection!
|
): DossierConnection!
|
||||||
|
groupeInstructeurs: [GroupeInstructeur!]!
|
||||||
id: ID!
|
id: ID!
|
||||||
instructeurs: [Profile!]!
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Le numero de la démarche.
|
Le numero de la démarche.
|
||||||
|
@ -279,6 +279,15 @@ type GeoJSON {
|
||||||
type: String!
|
type: String!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"""
|
||||||
|
Un groupe instructeur
|
||||||
|
"""
|
||||||
|
type GroupeInstructeur {
|
||||||
|
id: ID!
|
||||||
|
instructeurs: [Profile!]!
|
||||||
|
label: String!
|
||||||
|
}
|
||||||
|
|
||||||
"""
|
"""
|
||||||
An ISO 8601-encoded datetime
|
An ISO 8601-encoded datetime
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -18,7 +18,7 @@ module Types
|
||||||
field :updated_at, GraphQL::Types::ISO8601DateTime, null: false
|
field :updated_at, GraphQL::Types::ISO8601DateTime, null: false
|
||||||
field :archived_at, GraphQL::Types::ISO8601DateTime, null: true
|
field :archived_at, GraphQL::Types::ISO8601DateTime, null: true
|
||||||
|
|
||||||
field :instructeurs, [Types::ProfileType], null: false
|
field :groupe_instructeurs, [Types::GroupeInstructeurType], null: false
|
||||||
|
|
||||||
field :dossiers, Types::DossierType.connection_type, "Liste de tous les dossiers d'une démarche.", null: false do
|
field :dossiers, Types::DossierType.connection_type, "Liste de tous les dossiers d'une démarche.", null: false do
|
||||||
argument :ids, [ID], required: false, description: "Filtrer les dossiers par ID."
|
argument :ids, [ID], required: false, description: "Filtrer les dossiers par ID."
|
||||||
|
@ -32,8 +32,8 @@ module Types
|
||||||
object.aasm.current_state
|
object.aasm.current_state
|
||||||
end
|
end
|
||||||
|
|
||||||
def instructeurs
|
def groupe_instructeurs
|
||||||
Loaders::Association.for(Procedure, :instructeurs).load(object)
|
Loaders::Association.for(object.class, groupe_instructeurs: { procedure: [:administrateurs] }).load(object)
|
||||||
end
|
end
|
||||||
|
|
||||||
def dossiers(ids: nil, since: nil)
|
def dossiers(ids: nil, since: nil)
|
||||||
|
|
17
app/graphql/types/groupe_instructeur_type.rb
Normal file
17
app/graphql/types/groupe_instructeur_type.rb
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
module Types
|
||||||
|
class GroupeInstructeurType < Types::BaseObject
|
||||||
|
description "Un groupe instructeur"
|
||||||
|
|
||||||
|
global_id_field :id
|
||||||
|
field :label, String, null: false
|
||||||
|
field :instructeurs, [Types::ProfileType], null: false
|
||||||
|
end
|
||||||
|
|
||||||
|
def instructeurs
|
||||||
|
Loaders::Association.for(object.class, :instructeurs).load(object)
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.authorized?(object, context)
|
||||||
|
authorized_demarche?(object.procedure, context)
|
||||||
|
end
|
||||||
|
end
|
|
@ -167,14 +167,14 @@ class Dossier < ApplicationRecord
|
||||||
scope :with_notifications, -> do
|
scope :with_notifications, -> do
|
||||||
# This scope is meant to be composed, typically with Instructeur.followed_dossiers, which means that the :follows table is already INNER JOINed;
|
# This scope is meant to be composed, typically with Instructeur.followed_dossiers, which means that the :follows table is already INNER JOINed;
|
||||||
# it will fail otherwise
|
# it will fail otherwise
|
||||||
|
joined_dossiers = joins('LEFT OUTER JOIN "champs" ON "champs" . "dossier_id" = "dossiers" . "id" AND "champs" . "parent_id" IS NULL AND "champs" . "private" = FALSE AND "champs"."updated_at" > "follows"."demande_seen_at"')
|
||||||
# Relations passed to #or must be “structurally compatible”, i.e. query the same tables.
|
.joins('LEFT OUTER JOIN "champs" "champs_privates_dossiers" ON "champs_privates_dossiers" . "dossier_id" = "dossiers" . "id" AND "champs_privates_dossiers" . "parent_id" IS NULL AND "champs_privates_dossiers" . "private" = TRUE AND "champs_privates_dossiers"."updated_at" > "follows"."annotations_privees_seen_at"')
|
||||||
joined_dossiers = left_outer_joins(:champs, :champs_private, :avis, :commentaires)
|
.joins('LEFT OUTER JOIN "avis" ON "avis" . "dossier_id" = "dossiers" . "id" AND avis.updated_at > follows.avis_seen_at')
|
||||||
|
.joins('LEFT OUTER JOIN "commentaires" ON "commentaires" . "dossier_id" = "dossiers" . "id" and commentaires.updated_at > follows.messagerie_seen_at and "commentaires"."email" != \'contact@tps.apientreprise.fr\' AND "commentaires"."email" != \'contact@demarches-simplifiees.fr\'')
|
||||||
|
|
||||||
updated_demandes = joined_dossiers
|
updated_demandes = joined_dossiers
|
||||||
.where('champs.updated_at > follows.demande_seen_at')
|
.where('champs.updated_at > follows.demande_seen_at')
|
||||||
|
|
||||||
# We join `:champs` twice, the second time with `has_many :champs_privates`. ActiveRecord generates the SQL: 'LEFT OUTER JOIN "champs" "champs_privates_dossiers" ON …'. We can then use this `champs_privates_dossiers` alias to disambiguate the table in this WHERE clause.
|
|
||||||
updated_annotations = joined_dossiers
|
updated_annotations = joined_dossiers
|
||||||
.where('champs_privates_dossiers.updated_at > follows.annotations_privees_seen_at')
|
.where('champs_privates_dossiers.updated_at > follows.annotations_privees_seen_at')
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,12 @@ describe API::V2::GraphqlController do
|
||||||
createdAt
|
createdAt
|
||||||
updatedAt
|
updatedAt
|
||||||
archivedAt
|
archivedAt
|
||||||
|
groupeInstructeurs {
|
||||||
|
label
|
||||||
|
instructeurs {
|
||||||
|
email
|
||||||
|
}
|
||||||
|
}
|
||||||
champDescriptors {
|
champDescriptors {
|
||||||
id
|
id
|
||||||
type
|
type
|
||||||
|
@ -67,6 +73,7 @@ describe API::V2::GraphqlController do
|
||||||
archivedAt: nil,
|
archivedAt: nil,
|
||||||
createdAt: procedure.created_at.iso8601,
|
createdAt: procedure.created_at.iso8601,
|
||||||
updatedAt: procedure.updated_at.iso8601,
|
updatedAt: procedure.updated_at.iso8601,
|
||||||
|
groupeInstructeurs: [{ instructeurs: [], label: "défaut" }],
|
||||||
champDescriptors: procedure.types_de_champ.map do |tdc|
|
champDescriptors: procedure.types_de_champ.map do |tdc|
|
||||||
{
|
{
|
||||||
id: tdc.to_typed_id,
|
id: tdc.to_typed_id,
|
||||||
|
|
Loading…
Reference in a new issue