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
end
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)
.latest?(base_pipeline, actual_head_pipeline, data)
raise InvalidateReactiveCache
......@@ -1249,12 +1249,13 @@ class MergeRequest < ApplicationRecord
end || { status: :parsing }
end
def calculate_reactive_cache(identifier, *args)
def calculate_reactive_cache(identifier, current_user_id = nil, *args)
service_class = identifier.constantize
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
def all_commits
......
......@@ -41,7 +41,7 @@ module Ci
end
def serializer_params
{ project: project }
{ project: project, current_user: current_user }
end
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