diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-08 12:09:43 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-08 12:09:43 +0300 |
commit | f5050253469fc0961c02deec0e698ad62bdd9de5 (patch) | |
tree | 30bbd8f8b556fd5b730f0123921138ee1d6bdaa2 /app/models/users_statistics.rb | |
parent | f6cdec670b9b757fc2225a2c6627ab79765e5b8a (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/users_statistics.rb')
-rw-r--r-- | app/models/users_statistics.rb | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/app/models/users_statistics.rb b/app/models/users_statistics.rb index 1a500717efd..37a430015e5 100644 --- a/app/models/users_statistics.rb +++ b/app/models/users_statistics.rb @@ -1,16 +1,29 @@ # frozen_string_literal: true class UsersStatistics < ApplicationRecord - STATISTICS_NAMES = [ - :without_groups_and_projects, - :with_highest_role_guest, - :with_highest_role_reporter, - :with_highest_role_developer, - :with_highest_role_maintainer, - :with_highest_role_owner, - :bots, - :blocked - ].freeze + scope :order_created_at_desc, -> { order(created_at: :desc) } + + class << self + def latest + order_created_at_desc.first + end + end + + def active + [ + without_groups_and_projects, + with_highest_role_guest, + with_highest_role_reporter, + with_highest_role_developer, + with_highest_role_maintainer, + with_highest_role_owner, + bots + ].sum + end + + def total + active + blocked + end class << self def create_current_stats! |