perf(graphql): add graphql benchmark
This commit is contained in:
parent
902dc678de
commit
260d8d2fec
2 changed files with 29 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue