|
|
|
|
|
3class FetchCountryRegisterJob < ApplicationJob
|
|
4 HOST = 'https://country.register.gov.uk'
|
|
5 ENDPOINT = '/records.json?page-size=500'
|
|
|
|
|
|
8 rescue_from StandardError do |exception|
|
|
9 Appsignal.send_exception exception
|
|
|
|
|
- FeatureEnvy - refers to 'location' more than self (maybe move it to another class?) » reek
- TooManyStatements - has approx 6 statements » reek
- Complexity 3 » saikuro
|
|
|
13 countries.each do |country|
|
|
14 location = Location.find_or_initialize_by(code: country['country'])
|
|
|
|
16 location.name = country['name']
|
|
17 location.start_date = country['start-date']
|
|
18 location.end_date = country['end-date']
|
|
|
|
20 if location.changed? || location.new_record?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- UncommunicativeVariableName - has the variable name 'x' » reek
- Complexity 2 » saikuro
|
|
|
29 fetch_register.body.values.map { |x| x['item'].first }
|
|
|
|
|
- UncommunicativeVariableName - has the variable name 'f' » reek
- UtilityFunction - doesn't depend on instance state (maybe move it to another class?) » reek
- Complexity 2 » saikuro
|
|
|
33 Faraday.new(HOST) do |f|
|
|
34 f.response :follow_redirects
|
|
|
|
36 f.response :raise_error
|
|
37 f.adapter :net_http_persistent
|
|
|
|
|
|
|
- DuplicateMethodCall - calls 'request.options' 2 times » reek
- FeatureEnvy - refers to 'request' more than self (maybe move it to another class?) » reek
- Complexity 2 » saikuro
|
|
|
42 faraday.get(ENDPOINT) do |request|
|
|
43 request.options[:timeout] = TIMEOUT
|
|
44 request.options[:open_timeout] = TIMEOUT
|
|
|
|
|
|
|