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:
-rw-r--r--app/models/cycle_analytics.rb4
-rw-r--r--lib/gitlab/cycle_analytics/stage_summary.rb5
-rw-r--r--lib/gitlab/cycle_analytics/summary/issue.rb8
-rw-r--r--spec/lib/gitlab/cycle_analytics/stage_summary_spec.rb4
4 files changed, 15 insertions, 6 deletions
diff --git a/app/models/cycle_analytics.rb b/app/models/cycle_analytics.rb
index c6862c9733d..57082ae6087 100644
--- a/app/models/cycle_analytics.rb
+++ b/app/models/cycle_analytics.rb
@@ -7,7 +7,9 @@ class CycleAnalytics
end
def summary
- @summary ||= ::Gitlab::CycleAnalytics::StageSummary.new(@project, from: @options[:from]).data
+ @summary ||= ::Gitlab::CycleAnalytics::StageSummary.new(@project,
+ from: @options[:from],
+ current_user: @options[:current_user]).data
end
def stats
diff --git a/lib/gitlab/cycle_analytics/stage_summary.rb b/lib/gitlab/cycle_analytics/stage_summary.rb
index dd9e4ac2813..b34baf5b081 100644
--- a/lib/gitlab/cycle_analytics/stage_summary.rb
+++ b/lib/gitlab/cycle_analytics/stage_summary.rb
@@ -1,13 +1,14 @@
module Gitlab
module CycleAnalytics
class StageSummary
- def initialize(project, from:)
+ def initialize(project, from:, current_user:)
@project = project
@from = from
+ @current_user = current_user
end
def data
- [serialize(Summary::Issue.new(project: @project, from: @from)),
+ [serialize(Summary::Issue.new(project: @project, from: @from, current_user: @current_user)),
serialize(Summary::Commit.new(project: @project, from: @from)),
serialize(Summary::Deploy.new(project: @project, from: @from))]
end
diff --git a/lib/gitlab/cycle_analytics/summary/issue.rb b/lib/gitlab/cycle_analytics/summary/issue.rb
index 7d62164aae3..008468f24b9 100644
--- a/lib/gitlab/cycle_analytics/summary/issue.rb
+++ b/lib/gitlab/cycle_analytics/summary/issue.rb
@@ -2,12 +2,18 @@ module Gitlab
module CycleAnalytics
module Summary
class Issue < Base
+ def initialize(project:, from:, current_user:)
+ @project = project
+ @from = from
+ @current_user = current_user
+ end
+
def title
'New Issue'
end
def value
- @value ||= @project.issues.created_after(@from).count
+ @value ||= IssuesFinder.new(@current_user, project_id: @project.id).execute.created_after(@from).count
end
end
end
diff --git a/spec/lib/gitlab/cycle_analytics/stage_summary_spec.rb b/spec/lib/gitlab/cycle_analytics/stage_summary_spec.rb
index 77dbf1c79a5..fb6b6c4a8d2 100644
--- a/spec/lib/gitlab/cycle_analytics/stage_summary_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/stage_summary_spec.rb
@@ -2,9 +2,9 @@ require 'spec_helper'
describe Gitlab::CycleAnalytics::StageSummary, models: true do
let(:project) { create(:project) }
- let(:from) { Time.now }
+ let(:from) { 1.day.ago }
let(:user) { create(:user, :admin) }
- subject { described_class.new(project, from: Time.now).data }
+ subject { described_class.new(project, from: Time.now, current_user: user).data }
describe "#new_issues" do
it "finds the number of issues created after the 'from date'" do