Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-07-09 12:09:27 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-07-09 12:09:27 +0300
commitc3b45354d720654215eb0e7b8e718ba6ea2d7a96 (patch)
tree359066e91bad08ae8e404bb43316705b7b53993e /lib/gitlab
parent734708924b0f86ad3c23636bd6a8942d679daaf2 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab')
-rw-r--r--lib/gitlab/analytics/unique_visits.rb6
-rw-r--r--lib/gitlab/service_desk.rb16
-rw-r--r--lib/gitlab/service_desk_email.rb22
-rw-r--r--lib/gitlab/template/service_desk_template.rb21
-rw-r--r--lib/gitlab/usage_data.rb12
5 files changed, 72 insertions, 5 deletions
diff --git a/lib/gitlab/analytics/unique_visits.rb b/lib/gitlab/analytics/unique_visits.rb
index ba0447990b1..9dd7d048eec 100644
--- a/lib/gitlab/analytics/unique_visits.rb
+++ b/lib/gitlab/analytics/unique_visits.rb
@@ -43,9 +43,7 @@ module Gitlab
keys = TARGET_IDS.map { |target_id| key(target_id, week_of) }
Gitlab::Redis::SharedState.with do |redis|
- Gitlab::Instrumentation::RedisClusterValidator.allow_cross_slot_commands do
- redis.pfcount(*keys)
- end
+ redis.pfcount(*keys)
end
end
@@ -55,7 +53,7 @@ module Gitlab
raise "Invalid target id #{target_id}" unless TARGET_IDS.include?(target_id.to_s)
year_week = time.strftime('%G-%V')
- "#{target_id}-#{year_week}"
+ "#{target_id}-{#{year_week}}"
end
end
end
diff --git a/lib/gitlab/service_desk.rb b/lib/gitlab/service_desk.rb
new file mode 100644
index 00000000000..b3d6e890e03
--- /dev/null
+++ b/lib/gitlab/service_desk.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module ServiceDesk
+ # Check whether a project or GitLab instance can support the Service Desk
+ # feature. Use `project.service_desk_enabled?` to check whether it is
+ # enabled for a particular project.
+ def self.enabled?(project:)
+ supported? && project[:service_desk_enabled]
+ end
+
+ def self.supported?
+ Gitlab::IncomingEmail.enabled? && Gitlab::IncomingEmail.supports_wildcard?
+ end
+ end
+end
diff --git a/lib/gitlab/service_desk_email.rb b/lib/gitlab/service_desk_email.rb
new file mode 100644
index 00000000000..f8dba82cb40
--- /dev/null
+++ b/lib/gitlab/service_desk_email.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module ServiceDeskEmail
+ class << self
+ def enabled?
+ !!config&.enabled && config&.address.present?
+ end
+
+ def key_from_address(address)
+ wildcard_address = config&.address
+ return unless wildcard_address
+
+ Gitlab::IncomingEmail.key_from_address(address, wildcard_address: wildcard_address)
+ end
+
+ def config
+ Gitlab.config.service_desk_email
+ end
+ end
+ end
+end
diff --git a/lib/gitlab/template/service_desk_template.rb b/lib/gitlab/template/service_desk_template.rb
new file mode 100644
index 00000000000..edc62a92004
--- /dev/null
+++ b/lib/gitlab/template/service_desk_template.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module Template
+ class ServiceDeskTemplate < BaseTemplate
+ class << self
+ def extension
+ '.md'
+ end
+
+ def base_dir
+ '.gitlab/service_desk_templates/'
+ end
+
+ def finder(project)
+ Gitlab::Template::Finders::RepoTemplateFinder.new(project, self.base_dir, self.extension, self.categories)
+ end
+ end
+ end
+ end
+end
diff --git a/lib/gitlab/usage_data.rb b/lib/gitlab/usage_data.rb
index 146303855a9..ef714527a2a 100644
--- a/lib/gitlab/usage_data.rb
+++ b/lib/gitlab/usage_data.rb
@@ -478,11 +478,21 @@ module Gitlab
end
# rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def usage_activity_by_stage_create(time_period)
- {}.tap do |h|
+ {
+ deploy_keys: distinct_count(::DeployKey.where(time_period), :user_id),
+ keys: distinct_count(::Key.regular_keys.where(time_period), :user_id),
+ merge_requests: distinct_count(::MergeRequest.where(time_period), :author_id),
+ projects_with_disable_overriding_approvers_per_merge_request: count(::Project.where(time_period.merge(disable_overriding_approvers_per_merge_request: true))),
+ projects_without_disable_overriding_approvers_per_merge_request: count(::Project.where(time_period.merge(disable_overriding_approvers_per_merge_request: [false, nil]))),
+ remote_mirrors: distinct_count(::Project.with_remote_mirrors.where(time_period), :creator_id),
+ snippets: distinct_count(::Snippet.where(time_period), :author_id)
+ }.tap do |h|
h[:merge_requests_users] = merge_requests_users(time_period) if time_period.present?
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
# Omitted because no user, creator or author associated: `campaigns_imported_from_github`, `ldap_group_links`
# rubocop: disable CodeReuse/ActiveRecord