Skip to content

Commit

Permalink
fix(api.champs_loader): n+1
Browse files Browse the repository at this point in the history
  • Loading branch information
mfo committed Dec 19, 2024
1 parent 7ed76c0 commit a26afbe
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 33 deletions.
27 changes: 0 additions & 27 deletions app/graphql/loaders/champ.rb

This file was deleted.

8 changes: 2 additions & 6 deletions app/graphql/types/dossier_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,19 +162,15 @@ def avis(id: nil)

def champs(id: nil)
if id.present?
Loaders::Champ
.for(object, private: false)
.load(ApplicationRecord.id_from_typed_id(id))
object.project_champs_public.filter { _1.stable_id.to_s == ApplicationRecord.id_from_typed_id(id).to_s }
else
object.project_champs_public.filter(&:visible?)
end
end

def annotations(id: nil)
if id.present?
Loaders::Champ
.for(object, private: true)
.load(ApplicationRecord.id_from_typed_id(id))
object.project_champs_private.filter { _1.stable_id.to_s == ApplicationRecord.id_from_typed_id(id).to_s }
else
object.project_champs_private.filter(&:visible?)
end
Expand Down

0 comments on commit a26afbe

Please sign in to comment.