Class: TimezoneWorker
- Inherits:
-
Object
- Object
- TimezoneWorker
- Includes:
- Sidekiq::Job
- Defined in:
- app/workers/timezone_worker.rb
Overview
Sidekiq worker: timezone.
Instance Method Summary collapse
Instance Method Details
#perform(party_id = nil) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/workers/timezone_worker.rb', line 9 def perform(party_id = nil) if party_id party = Party.find(party_id) result = PartyRecordTimezone.new.process party if result.timezone_recorded? logger.info "[timezone] Party ID: #{party.id} -> timezone updated to #{result.timezone.name}" else logger.error "[timezone] Party ID: #{party.id} -> timezone could not be updated #{result..join(', ')}" end else # Going to limit this to accounts updated in the last 3 months only party_ids = Party.where(type: %w[Contact Customer]).where(timezone_name: nil).where.not(state: 'guest').where(updated_at: 3.months.ago..).ids logger.info "[timezone] Enqueuing #{party_ids.size} parties to populate timezone" party_ids.each do |party_id| TimezoneWorker.perform_async(party_id) end end end |