[go: up one dir, main page]

Skip to content

Update user counts when applying a new SM license

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Problem

The Users in subscription / Billable users / Maximum users / Users over subscription counts are updated once a day through background jobs.

When applying a new license, the counts are not automatically updated so admins still see the user counts from the previous license until the next time the job runs.

Click to expand screenshot Screenshot_2023-09-26_at_10.02.06_AM

Related to #370026 (closed)

Proposal

If the license being created is starting on the current date or has already started, enqueue the Analytics::UsageTrends::CountJobTriggerWorker job to refresh the billable users count right after the license creation.

# ee/app/models/license.rb

after_create :update_billable_user_counts

def update_user_counts
  return unless started?

  identifier = Analytics::UsageTrends::Measurement.identifiers[:billable_users]
  ::Analytics::UsageTrends::CounterJobWorker.perform_async(identifier, User.minimum(:id), User.maximum(:id), Time.zone.now)
end
Edited by 🤖 GitLab Bot 🤖