Merge pull request #10923 from tchak/graphql-siret-address-optimize

fix(graphql): parse_etablissement_address is slow (up to 300ms) – bypasse it when possible
This commit is contained in:
Paul Chavard 2024-10-14 08:14:51 +00:00 committed by GitHub
commit 32d8cbfe48
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 3 deletions

View file

@ -124,8 +124,11 @@ module Types
field :complement_adresse, String, null: true, deprecation_reason: "Utilisez le champ `address` à la place."
def address
APIGeoService
.parse_etablissement_address(object)
address = object.champ&.value_json
if address.blank? || !address.key?("departement_code")
address = APIGeoService.parse_etablissement_address(object)
end
address
.merge(label: object.adresse, type: "housenumber")
.with_indifferent_access
end

View file

@ -122,8 +122,9 @@ describe API::V2::GraphqlController do
end
context 'with entreprise' do
let(:types_de_champ_public) { [{ type: :siret }] }
let(:procedure) { create(:procedure, :published, :with_service, administrateurs: [admin], types_de_champ_public:) }
let(:dossier) { create(:dossier, :en_construction, :with_entreprise, procedure: procedure) }
let(:dossier) { create(:dossier, :en_construction, :with_entreprise, :with_populated_champs, procedure: procedure) }
it {
expect(gql_errors).to be_nil