|
1class BackfillConstituenciesJob < ApplicationJob
|
|
|
|
|
- TooManyStatements - has approx 8 statements » reek
- Complexity 6 » saikuro
|
4 def perform(id: 0, since: nil)
|
|
5 return if Site.disable_constituency_api?
|
|
|
|
7 since = since.try(:in_time_zone)
|
|
8 signatures = signatures_missing_constituency_id(id, since).to_a
|
|
9 max_id = signatures.map(&:id).max
|
|
|
|
11 signatures.each do |signature|
|
|
12 next if signature.constituency_id?
|
|
|
- Found = in conditional. It should probably be an == » roodi
|
14 if constituency = signature.constituency
|
|
15 signature.update_column(:constituency_id, constituency.external_id)
|
|
|
|
|
|
|
|
19 if reschedule?(max_id, since)
|
|
20 self.class.perform_later(id: max_id, since: since.try(:iso8601))
|
|
|
|
|
|
|
|
|
|
|
- UtilityFunction - doesn't depend on instance state (maybe move it to another class?) » reek
- Complexity 1 » saikuro
|
26 def signatures_missing_constituency_id(id, since)
|
|
27 Signature.missing_constituency_id(since: since).batch(id)
|
|
|
|
|
|
30 def reschedule?(id, since)
|
|
31 signatures_missing_constituency_id(id, since).exists?
|
|
|
|
|