[graphql] add dossiersCount field
visible only for admin
This commit is contained in:
parent
7684e97494
commit
886f595350
3 changed files with 10 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
|||
module Types
|
||||
class DemarcheDescriptorType < Types::BaseObject
|
||||
field_class BaseField
|
||||
description "Une démarche (métadonnées)
|
||||
Ceci est une version abrégée du type `Demarche`, qui n’expose que les métadonnées.
|
||||
Cela évite l’accès récursif aux dossiers."
|
||||
|
@ -23,6 +24,8 @@ Cela évite l’accès récursif aux dossiers."
|
|||
field :cadre_juridique, String, null: true
|
||||
field :deliberation, String, null: true
|
||||
|
||||
field :dossiers_count, Int, null: false, require_admin: true
|
||||
|
||||
def service
|
||||
Loaders::Record.for(Service).load(procedure.service_id)
|
||||
end
|
||||
|
@ -31,6 +34,10 @@ Cela évite l’accès récursif aux dossiers."
|
|||
object.is_a?(ProcedureRevision) ? object : object.active_revision
|
||||
end
|
||||
|
||||
def dossiers_count
|
||||
object.dossiers.count
|
||||
end
|
||||
|
||||
def deliberation
|
||||
Rails.application.routes.url_helpers.url_for(procedure.deliberation) if procedure.deliberation.attached?
|
||||
end
|
||||
|
|
|
@ -44,6 +44,7 @@ class DemarchesPubliquesExportService
|
|||
service { nom organisme typeOrganisme }
|
||||
cadreJuridique
|
||||
deliberation
|
||||
dossiersCount
|
||||
revision {
|
||||
champDescriptors {
|
||||
type
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
describe DemarchesPubliquesExportService do
|
||||
let(:procedure) { create(:procedure, :published, :with_service, :with_type_de_champ) }
|
||||
let!(:dossier) { create(:dossier, procedure: procedure) }
|
||||
let(:io) { StringIO.new }
|
||||
|
||||
describe 'call' do
|
||||
|
@ -16,6 +17,7 @@ describe DemarchesPubliquesExportService do
|
|||
cadreJuridique: "un cadre juridique important",
|
||||
deliberation: nil,
|
||||
datePublication: procedure.published_at.iso8601,
|
||||
dossiersCount: 1,
|
||||
revision: {
|
||||
champDescriptors: [
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue