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:
commit
32d8cbfe48
2 changed files with 7 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue