fix(graphql): parse_etablissement_address is slow (300ms) – bypasse it when possible
This commit is contained in:
parent
8266f7ff6c
commit
b027839721
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."
|
field :complement_adresse, String, null: true, deprecation_reason: "Utilisez le champ `address` à la place."
|
||||||
|
|
||||||
def address
|
def address
|
||||||
APIGeoService
|
address = object.champ&.value_json
|
||||||
.parse_etablissement_address(object)
|
if address.blank? || !address.key?("departement_code")
|
||||||
|
address = APIGeoService.parse_etablissement_address(object)
|
||||||
|
end
|
||||||
|
address
|
||||||
.merge(label: object.adresse, type: "housenumber")
|
.merge(label: object.adresse, type: "housenumber")
|
||||||
.with_indifferent_access
|
.with_indifferent_access
|
||||||
end
|
end
|
||||||
|
|
|
@ -122,8 +122,9 @@ describe API::V2::GraphqlController do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with entreprise' do
|
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(: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 {
|
it {
|
||||||
expect(gql_errors).to be_nil
|
expect(gql_errors).to be_nil
|
||||||
|
|
Loading…
Add table
Reference in a new issue