Skip to content

Commit

Permalink
Introduce metrics for user global roles
Browse files Browse the repository at this point in the history
Co-authored-by: Saray Cabrera Padrón <scabrerapadron@suse.de>
  • Loading branch information
eduardoj and saraycp committed Oct 30, 2020
1 parent 0e911e7 commit 2b6c66a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/api/app/jobs/measurements_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ class MeasurementsJob < ApplicationJob

def perform
RabbitmqBus.send_to_bus('metrics', "group count=#{Group.count}")
RabbitmqBus.send_to_bus('metrics', "user in_beta=#{User.in_beta.count},in_rollout=#{User.in_rollout.count},count=#{User.count},#{state_fields}")
RabbitmqBus.send_to_bus('metrics', "user in_beta=#{User.in_beta.count},in_rollout=#{User.in_rollout.count},count=#{User.count},#{role_fields},#{state_fields}")
end

private

def role_fields
Role.global.pluck(:title).map { |role_title| "#{role_title.downcase}=#{Role.find_by(title: role_title).users.count}" }.join(',')
end

def state_fields
User::STATES.map { |state| "#{state}=#{User.where(state: state).count}" }.join(',')
end
Expand Down

0 comments on commit 2b6c66a

Please sign in to comment.