Class: Identity::UserAcceptableVerifiedCredentialTotalsJob

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Job
Defined in:
app/sidekiq/identity/user_acceptable_verified_credential_totals_job.rb

Constant Summary collapse

STATSD_KEY_PREFIX =
'worker.user_avc_totals'
SCOPES =
[WITH_AVC = :with_avc,
WITH_IVC = :with_ivc,
WITHOUT_AVC = :without_avc,
WITHOUT_IVC = :without_ivc,
WITHOUT_AVC_IVC = :without_avc_ivc].freeze
PROVIDERS =
[ALL = :all,
IDME = :idme,
LOGINGOV = :logingov,
DSLOGON = :dslogon,
MHV = :mhv].freeze

Instance Method Summary collapse

Instance Method Details

#performObject

[View source] [View on GitHub]

21
22
23
# File 'app/sidekiq/identity/user_acceptable_verified_credential_totals_job.rb', line 21

def perform
  set_statsd_gauges
end

#set_statsd_gaugesObject (private)

Set StatsD gauge for all user_avc_totals..[SCOPES].total combinations

[View source] [View on GitHub]

29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'app/sidekiq/identity/user_acceptable_verified_credential_totals_job.rb', line 29

def set_statsd_gauges
  base_query = UserAcceptableVerifiedCredential.joins(user_account: :user_verifications).distinct

  SCOPES.each do |scope|
    mhv_dslogon_combined_total = 0
    scoped_query = base_query.merge(UserAcceptableVerifiedCredential.public_send(scope))

    PROVIDERS.each do |provider|
      count = if provider == ALL
                scoped_query.count
              else
                scoped_query.merge(UserVerification.public_send(provider)).count
              end

      StatsD.gauge("#{STATSD_KEY_PREFIX}.#{provider}.#{scope}.total", count)

      # MHV and DSLOGON combined total
      mhv_dslogon_combined_total += count if [MHV, DSLOGON].include?(provider)
    end

    # MHV_DSLOGON Combined gauge
    StatsD.gauge("#{STATSD_KEY_PREFIX}.#{MHV}_#{DSLOGON}.#{scope}.total", mhv_dslogon_combined_total)
  end
end