Commit 3ffdae92 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'backport-add-current-user-compare-services-ce' into 'master'

Backport changes for 16252 in EE add current_user to report comparison services

See merge request gitlab-org/gitlab-ce!32920
parents f95857c8 0a5bce6e
...@@ -1239,7 +1239,7 @@ class MergeRequest < ApplicationRecord ...@@ -1239,7 +1239,7 @@ class MergeRequest < ApplicationRecord
end end
def compare_reports(service_class, current_user = nil) def compare_reports(service_class, current_user = nil)
with_reactive_cache(service_class.name) do |data| with_reactive_cache(service_class.name, current_user&.id) do |data|
unless service_class.new(project, current_user) unless service_class.new(project, current_user)
.latest?(base_pipeline, actual_head_pipeline, data) .latest?(base_pipeline, actual_head_pipeline, data)
raise InvalidateReactiveCache raise InvalidateReactiveCache
...@@ -1249,12 +1249,13 @@ class MergeRequest < ApplicationRecord ...@@ -1249,12 +1249,13 @@ class MergeRequest < ApplicationRecord
end || { status: :parsing } end || { status: :parsing }
end end
def calculate_reactive_cache(identifier, *args) def calculate_reactive_cache(identifier, current_user_id = nil, *args)
service_class = identifier.constantize service_class = identifier.constantize
raise NameError, service_class unless service_class < Ci::CompareReportsBaseService raise NameError, service_class unless service_class < Ci::CompareReportsBaseService
service_class.new(project).execute(base_pipeline, actual_head_pipeline) current_user = User.find_by(id: current_user_id)
service_class.new(project, current_user).execute(base_pipeline, actual_head_pipeline)
end end
def all_commits def all_commits
......
...@@ -41,7 +41,7 @@ module Ci ...@@ -41,7 +41,7 @@ module Ci
end end
def serializer_params def serializer_params
{ project: project } { project: project, current_user: current_user }
end end
def get_report(pipeline) def get_report(pipeline)
......
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