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>2023-02-15 12:07:30 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-02-15 12:07:30 +0300
commit50e177d19bdeeb0fcc7b129b9c30841454df240b (patch)
tree11b30123cfec778cfa469bc23e17f40a45d43880 /lib/gitlab/usage
parent9cf113df885ac8959b9fab3aab5e50e2532fef75 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/usage')
-rw-r--r--lib/gitlab/usage/metrics/instrumentations/jira_active_integrations_metric.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/gitlab/usage/metrics/instrumentations/jira_active_integrations_metric.rb b/lib/gitlab/usage/metrics/instrumentations/jira_active_integrations_metric.rb
new file mode 100644
index 00000000000..13af3937f43
--- /dev/null
+++ b/lib/gitlab/usage/metrics/instrumentations/jira_active_integrations_metric.rb
@@ -0,0 +1,36 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module Usage
+ module Metrics
+ module Instrumentations
+ class JiraActiveIntegrationsMetric < DatabaseMetric
+ operation :count
+
+ def initialize(metric_definition)
+ super
+
+ deployment_type = options[:deployment_type]
+
+ return if deployment_type.in?(allowed_types)
+
+ raise ArgumentError, "deployment_type '#{deployment_type}' must be one of: #{allowed_types.join(', ')}"
+ end
+
+ relation do |options|
+ ::Integrations::Jira
+ .active
+ .joins(:jira_tracker_data)
+ .where(jira_tracker_data: { deployment_type: options[:deployment_type] })
+ end
+
+ private
+
+ def allowed_types
+ Integrations::JiraTrackerData.deployment_types.keys
+ end
+ end
+ end
+ end
+ end
+end