diff --git a/app/services/serializer_service.rb b/app/services/serializer_service.rb index e229861d6..68de41017 100644 --- a/app/services/serializer_service.rb +++ b/app/services/serializer_service.rb @@ -4,6 +4,11 @@ class SerializerService data && data['dossier'] end + def self.dossiers(procedure) + data = execute_query('serializeDossiers', { number: procedure.id }) + data && data['demarche']['dossiers'] + end + def self.avis(avis) data = execute_query('serializeAvis', { number: avis.dossier_id, id: avis.to_typed_id }) data && data['dossier']['avis'].first @@ -31,6 +36,20 @@ class SerializerService end QUERY = <<-'GRAPHQL' + query serializeDossiers($number: Int!, $after: String) { + demarche(number: $number) { + dossiers(after: $after) { + nodes { + ...DossierFragment + } + pageInfo { + hasNextPage + endCursor + } + } + } + } + query serializeDossier($number: Int!) { dossier(number: $number) { ...DossierFragment diff --git a/lib/tasks/benchmarks.rake b/lib/tasks/benchmarks.rake index f363e17e7..716fbafe8 100644 --- a/lib/tasks/benchmarks.rake +++ b/lib/tasks/benchmarks.rake @@ -8,4 +8,14 @@ namespace :benchmarks do x.report("Démarche 55824") { ProcedureExportService.new(p_55824, p_55824.dossiers).to_xlsx } end end + + desc 'Benchmark graphql' + task graphql: :environment do + p_45964 = Procedure.find(45964) + p_55824 = Procedure.find(55824) + Benchmark.bm do |x| + x.report("Démarche 45964") { SerializerService.dossiers(p_45964) } + x.report("Démarche 55824") { SerializerService.dossiers(p_55824) } + end + end end