Skip to content

Commit

Permalink
Merge pull request #10360 from eduardoj/user_states_roles_measurements
Browse files Browse the repository at this point in the history
Introduce measurements for user states and user roles
  • Loading branch information
hennevogel committed Oct 30, 2020
2 parents 311cfdc + 484fb48 commit 9e68dcd
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/api/app/jobs/measurements_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,19 @@ class MeasurementsJob < ApplicationJob
queue_as :quick

def perform
return unless CONFIG['amqp_options']

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}")
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
end

0 comments on commit 9e68dcd

Please sign in to comment.