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:
authorAakriti Gupta <agupta@gitlab.com>2019-11-06 19:07:11 +0300
committerAakriti Gupta <agupta@gitlab.com>2019-11-20 12:35:58 +0300
commit9e674f92a3e3f2c4f524517cfa31864525844095 (patch)
tree6a8547acea5dfd13d3e50580fec644f0710b4acb /lib/gitlab/cycle_analytics
parent7bc0aff0b4e15fce828621d7e0919d84368f3d2b (diff)
Prevent guests from seeing commits for cycle analytics
- if the user has access level lower than REPORTER, don't include commit count in summary
Diffstat (limited to 'lib/gitlab/cycle_analytics')
-rw-r--r--lib/gitlab/cycle_analytics/stage_summary.rb22
1 files changed, 19 insertions, 3 deletions
diff --git a/lib/gitlab/cycle_analytics/stage_summary.rb b/lib/gitlab/cycle_analytics/stage_summary.rb
index ea440c441b7..9c75d4bb455 100644
--- a/lib/gitlab/cycle_analytics/stage_summary.rb
+++ b/lib/gitlab/cycle_analytics/stage_summary.rb
@@ -11,13 +11,29 @@ module Gitlab
end
def data
- [serialize(Summary::Issue.new(project: @project, from: @from, to: @to, current_user: @current_user)),
- serialize(Summary::Commit.new(project: @project, from: @from, to: @to)),
- serialize(Summary::Deploy.new(project: @project, from: @from, to: @to))]
+ summary = [issue_stats]
+ summary << commit_stats if user_has_sufficient_access?
+ summary << deploy_stats
end
private
+ def issue_stats
+ serialize(Summary::Issue.new(project: @project, from: @from, to: @to, current_user: @current_user))
+ end
+
+ def commit_stats
+ serialize(Summary::Commit.new(project: @project, from: @from, to: @to))
+ end
+
+ def deploy_stats
+ serialize(Summary::Deploy.new(project: @project, from: @from, to: @to))
+ end
+
+ def user_has_sufficient_access?
+ @project.team.member?(@current_user, Gitlab::Access::REPORTER)
+ end
+
def serialize(summary_object)
AnalyticsSummarySerializer.new.represent(summary_object)
end