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."
|
||||
|
||||
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