Commit 58dddcdf authored by James Lopez's avatar James Lopez

few fixes after merge

parent 69ecd951
...@@ -7,7 +7,9 @@ class CycleAnalytics ...@@ -7,7 +7,9 @@ class CycleAnalytics
end end
def summary 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 end
def stats def stats
......
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
class StageSummary class StageSummary
def initialize(project, from:) def initialize(project, from:, current_user:)
@project = project @project = project
@from = from @from = from
@current_user = current_user
end end
def data 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::Commit.new(project: @project, from: @from)),
serialize(Summary::Deploy.new(project: @project, from: @from))] serialize(Summary::Deploy.new(project: @project, from: @from))]
end end
......
...@@ -2,12 +2,18 @@ module Gitlab ...@@ -2,12 +2,18 @@ module Gitlab
module CycleAnalytics module CycleAnalytics
module Summary module Summary
class Issue < Base class Issue < Base
def initialize(project:, from:, current_user:)
@project = project
@from = from
@current_user = current_user
end
def title def title
'New Issue' 'New Issue'
end end
def value 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 end
end end
......
...@@ -2,9 +2,9 @@ require 'spec_helper' ...@@ -2,9 +2,9 @@ require 'spec_helper'
describe Gitlab::CycleAnalytics::StageSummary, models: true do describe Gitlab::CycleAnalytics::StageSummary, models: true do
let(:project) { create(:project) } let(:project) { create(:project) }
let(:from) { Time.now } let(:from) { 1.day.ago }
let(:user) { create(:user, :admin) } 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 describe "#new_issues" do
it "finds the number of issues created after the 'from date'" do it "finds the number of issues created after the 'from date'" do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment