Skip to content

Commit

Permalink
Merge pull request #23 from openownership/fix-opencorporates-timeout
Browse files Browse the repository at this point in the history
Increased OpenCorporates timeout and used sparse where possible
  • Loading branch information
spacesnottabs authored Aug 16, 2023
2 parents b189a9f + 5740326 commit 1704761
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions app/controllers/entities_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def show
end

# Conversion
@oc_data = get_opencorporates_company_hash(entity) || {}
@oc_data = get_opencorporates_company_hash(entity, sparse: true) || {}

respond_to do |format|
format.html
Expand Down Expand Up @@ -132,7 +132,7 @@ def raw
@raw_data_records = RAW_DATA_RECORD_REPOSITORY.all_for_entity(entity)
return if @raw_data_records.empty?

@oc_data = get_opencorporates_company_hash(entity) || {}
@oc_data = get_opencorporates_company_hash(entity, sparse: true) || {}
@newest = RAW_DATA_RECORD_REPOSITORY.newest_for_entity_date(entity)
@oldest = RAW_DATA_RECORD_REPOSITORY.oldest_for_entity_date(entity)
@data_sources = DATA_SOURCE_REPOSITORY.all_for_raw_records(@raw_data_records)
Expand Down Expand Up @@ -187,10 +187,10 @@ def similar_people(entity)
ENTITY_SERVICE.search({ q: entity.name, type: 'personStatement' }, exclude_identifiers: entity.identifiers)
end

def get_opencorporates_company_hash(entity)
def get_opencorporates_company_hash(entity, sparse: false)
return unless entity.jurisdiction_code? && entity.company_number?

client = OpencorporatesClient.new_for_app timeout: 2.0
client.get_company(entity.jurisdiction_code, entity.company_number, sparse: false)
client = OpencorporatesClient.new_for_app timeout: 5.0
client.get_company(entity.jurisdiction_code, entity.company_number, sparse:)
end
end

0 comments on commit 1704761

Please sign in to comment.