summaryrefslogtreecommitdiff
path: root/app/models/users_statistics.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/users_statistics.rb')
-rw-r--r--app/models/users_statistics.rb33
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!