From f5050253469fc0961c02deec0e698ad62bdd9de5 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Wed, 8 Apr 2020 09:09:43 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- app/models/application_setting.rb | 3 +++ app/models/application_setting_implementation.rb | 1 + app/models/users_statistics.rb | 33 +++++++++++++++++------- 3 files changed, 27 insertions(+), 10 deletions(-) (limited to 'app/models') diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index 9254f7dd633..c1e44748304 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -142,6 +142,9 @@ class ApplicationSetting < ApplicationRecord validates :default_artifacts_expire_in, presence: true, duration: true + validates :container_expiration_policies_enable_historic_entries, + inclusion: { in: [true, false], message: 'must be a boolean value' } + validates :container_registry_token_expire_delay, presence: true, numericality: { only_integer: true, greater_than: 0 } diff --git a/app/models/application_setting_implementation.rb b/app/models/application_setting_implementation.rb index 418fb18cc91..920ad3286d1 100644 --- a/app/models/application_setting_implementation.rb +++ b/app/models/application_setting_implementation.rb @@ -42,6 +42,7 @@ module ApplicationSettingImplementation asset_proxy_enabled: false, authorized_keys_enabled: true, # TODO default to false if the instance is configured to use AuthorizedKeysCommand commit_email_hostname: default_commit_email_hostname, + container_expiration_policies_enable_historic_entries: false, container_registry_token_expire_delay: 5, default_artifacts_expire_in: '30 days', default_branch_protection: Settings.gitlab['default_branch_protection'], 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! -- cgit v1.2.3