summaryrefslogtreecommitdiff
path: root/lib/gitlab/cycle_analytics
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-06-16 18:25:58 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-06-16 18:25:58 +0000
commita5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (patch)
treefb69158581673816a8cd895f9d352dcb3c678b1e /lib/gitlab/cycle_analytics
parentd16b2e8639e99961de6ddc93909f3bb5c1445ba1 (diff)
downloadgitlab-ce-a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4.tar.gz
Add latest changes from gitlab-org/gitlab@14-0-stable-eev14.0.0-rc42
Diffstat (limited to 'lib/gitlab/cycle_analytics')
-rw-r--r--lib/gitlab/cycle_analytics/stage_summary.rb17
-rw-r--r--lib/gitlab/cycle_analytics/summary/base.rb5
-rw-r--r--lib/gitlab/cycle_analytics/summary/commit.rb2
-rw-r--r--lib/gitlab/cycle_analytics/summary/deploy.rb2
-rw-r--r--lib/gitlab/cycle_analytics/summary/deployment_frequency.rb6
-rw-r--r--lib/gitlab/cycle_analytics/summary/issue.rb15
6 files changed, 25 insertions, 22 deletions
diff --git a/lib/gitlab/cycle_analytics/stage_summary.rb b/lib/gitlab/cycle_analytics/stage_summary.rb
index 7559cd376bf..b309802f296 100644
--- a/lib/gitlab/cycle_analytics/stage_summary.rb
+++ b/lib/gitlab/cycle_analytics/stage_summary.rb
@@ -3,10 +3,9 @@
module Gitlab
module CycleAnalytics
class StageSummary
- def initialize(project, from:, to: nil, current_user:)
+ def initialize(project, options:, current_user:)
@project = project
- @from = from
- @to = to
+ @options = options
@current_user = current_user
end
@@ -20,15 +19,15 @@ module Gitlab
private
def issue_stats
- serialize(Summary::Issue.new(project: @project, from: @from, to: @to, current_user: @current_user))
+ serialize(Summary::Issue.new(project: @project, options: @options, current_user: @current_user))
end
def commit_stats
- serialize(Summary::Commit.new(project: @project, from: @from, to: @to))
+ serialize(Summary::Commit.new(project: @project, options: @options))
end
def deployments_summary
- @deployments_summary ||= Summary::Deploy.new(project: @project, from: @from, to: @to)
+ @deployments_summary ||= Summary::Deploy.new(project: @project, options: @options)
end
def deploy_stats
@@ -39,8 +38,7 @@ module Gitlab
serialize(
Summary::DeploymentFrequency.new(
deployments: deployments_summary.value.raw_value,
- from: @from,
- to: @to),
+ options: @options),
with_unit: true
)
end
@@ -50,8 +48,7 @@ module Gitlab
end
def serialize(summary_object, with_unit: false)
- AnalyticsSummarySerializer.new.represent(
- summary_object, with_unit: with_unit)
+ AnalyticsSummarySerializer.new.represent(summary_object, with_unit: with_unit)
end
end
end
diff --git a/lib/gitlab/cycle_analytics/summary/base.rb b/lib/gitlab/cycle_analytics/summary/base.rb
index 67ad75652b0..50a8f189df0 100644
--- a/lib/gitlab/cycle_analytics/summary/base.rb
+++ b/lib/gitlab/cycle_analytics/summary/base.rb
@@ -4,10 +4,9 @@ module Gitlab
module CycleAnalytics
module Summary
class Base
- def initialize(project:, from:, to: nil)
+ def initialize(project:, options:)
@project = project
- @from = from
- @to = to
+ @options = options
end
def title
diff --git a/lib/gitlab/cycle_analytics/summary/commit.rb b/lib/gitlab/cycle_analytics/summary/commit.rb
index 1dc9d5de966..fb55c3df869 100644
--- a/lib/gitlab/cycle_analytics/summary/commit.rb
+++ b/lib/gitlab/cycle_analytics/summary/commit.rb
@@ -21,7 +21,7 @@ module Gitlab
def commits_count
return unless ref
- @commits_count ||= gitaly_commit_client.commit_count(ref, after: @from, before: @to)
+ @commits_count ||= gitaly_commit_client.commit_count(ref, after: @options[:from], before: @options[:to])
end
def gitaly_commit_client
diff --git a/lib/gitlab/cycle_analytics/summary/deploy.rb b/lib/gitlab/cycle_analytics/summary/deploy.rb
index e5bf6ef616f..ea16226a865 100644
--- a/lib/gitlab/cycle_analytics/summary/deploy.rb
+++ b/lib/gitlab/cycle_analytics/summary/deploy.rb
@@ -16,7 +16,7 @@ module Gitlab
def deployments_count
DeploymentsFinder
- .new(project: @project, finished_after: @from, finished_before: @to, status: :success, order_by: :finished_at)
+ .new(project: @project, finished_after: @options[:from], finished_before: @options[:to], status: :success, order_by: :finished_at)
.execute
.count
end
diff --git a/lib/gitlab/cycle_analytics/summary/deployment_frequency.rb b/lib/gitlab/cycle_analytics/summary/deployment_frequency.rb
index 00676a02a6f..1947866d772 100644
--- a/lib/gitlab/cycle_analytics/summary/deployment_frequency.rb
+++ b/lib/gitlab/cycle_analytics/summary/deployment_frequency.rb
@@ -6,10 +6,10 @@ module Gitlab
class DeploymentFrequency < Base
include SummaryHelper
- def initialize(deployments:, from:, to: nil, project: nil)
+ def initialize(deployments:, options:, project: nil)
@deployments = deployments
- super(project: project, from: from, to: to)
+ super(project: project, options: options)
end
def title
@@ -17,7 +17,7 @@ module Gitlab
end
def value
- @value ||= frequency(@deployments, @from, @to || Time.now)
+ @value ||= frequency(@deployments, @options[:from], @options[:to] || Time.current)
end
def unit
diff --git a/lib/gitlab/cycle_analytics/summary/issue.rb b/lib/gitlab/cycle_analytics/summary/issue.rb
index 462fd4c2d3d..34e0d34b960 100644
--- a/lib/gitlab/cycle_analytics/summary/issue.rb
+++ b/lib/gitlab/cycle_analytics/summary/issue.rb
@@ -4,10 +4,9 @@ module Gitlab
module CycleAnalytics
module Summary
class Issue < Base
- def initialize(project:, from:, to: nil, current_user:)
+ def initialize(project:, options:, current_user:)
@project = project
- @from = from
- @to = to
+ @options = options
@current_user = current_user
end
@@ -23,10 +22,18 @@ module Gitlab
def issues_count
IssuesFinder
- .new(@current_user, project_id: @project.id, created_after: @from, created_before: @to)
+ .new(@current_user, finder_params)
.execute
.count
end
+
+ def finder_params
+ @options.dup.tap do |hash|
+ hash[:created_after] = hash.delete(:from)
+ hash[:created_before] = hash.delete(:to)
+ hash[:project_id] = @project.id
+ end
+ end
end
end
end