Class: PartyProfileImageWorker

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Job, Sidekiq::Status::Worker
Defined in:
app/workers/party_profile_image_worker.rb

Overview

Background worker to lookup and attach profile images for parties.
Uses Clearbit Logo API for company logos.

Examples:

Single party lookup

PartyProfileImageWorker.perform_async(party_id: customer.id)

Force refresh

PartyProfileImageWorker.perform_async(party_id: customer.id, force: true)

Bulk enqueue all missing

PartyProfileImageWorker.perform_async

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.track_in_jobs_panel?Boolean

Keep this worker out of the global Jobs panel. Every enqueue is an invisible
lazy backfill the user never initiated — fired on contact-card render, on
contact/customer #show, per matched party in the phone popup, on new-customer
creation, and on social-login avatar fetch — with no result page the user is
waiting on. Surfacing it spammed CRM users with "Party Profile Image /
Starting…" toasts (often several per page). Sidekiq::Status is included only
for the admin bulk-enqueue progress, still viewable at /jobs/:jid.
See Sidekiq::TrackEnqueuedStatusJobsMiddleware.

Returns:

  • (Boolean)


29
# File 'app/workers/party_profile_image_worker.rb', line 29

def self.track_in_jobs_panel? = false

Instance Method Details

#perform(party_id = nil, options = {}) ⇒ Object

Parameters:

  • party_id (Integer, nil) (defaults to: nil)

    Party ID, or nil to bulk enqueue all missing

  • options (Hash) (defaults to: {})

    Additional options

Options Hash (options):

  • :force (Boolean)

    Force refresh even if image exists



34
35
36
37
38
39
40
41
42
# File 'app/workers/party_profile_image_worker.rb', line 34

def perform(party_id = nil, options = {})
  options = options.symbolize_keys

  if party_id.nil?
    bulk_enqueue(options)
  else
    process_party(party_id, options)
  end
end