refactor(graphql): use champ_for_update method

This commit is contained in:
Paul Chavard 2024-03-27 11:35:42 +01:00
parent 25e009df78
commit fbd48abc9c
2 changed files with 11 additions and 7 deletions

View file

@ -39,10 +39,12 @@ module Mutations
def find_annotation(dossier, annotation_id)
stable_id, row_id = Champ.decode_typed_id(annotation_id)
type_de_champ = dossier.revision.types_de_champ
.private_only
.find_by(type_champ: annotation_type_champ, stable_id:)
Champ.joins(:type_de_champ).find_by(type_de_champ: {
type_champ: annotation_type_champ, stable_id:, private: true
}, private: true, row_id:, dossier:)
return nil if type_de_champ.nil?
dossier.champ_for_update(type_de_champ, row_id)
end
def annotation_type_champ

View file

@ -26,11 +26,13 @@ module Mutations
private
def find_annotation(dossier, annotation_id)
stable_id, row_id = Champ.decode_typed_id(annotation_id)
stable_id, _row_id = Champ.decode_typed_id(annotation_id)
type_de_champ = dossier.revision.types_de_champ
.private_only
.find_by(type_champ: TypeDeChamp.type_champs.fetch(:repetition), stable_id:)
Champ.joins(:type_de_champ).find_by(type_de_champ: {
type_champ: TypeDeChamp.type_champs.fetch(:repetition), stable_id:, private: true
}, private: true, row_id:, dossier:)
return nil if type_de_champ.nil?
dossier.project_champ(type_de_champ, nil)
end
end
end