2018-10-06 19:10:08 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-05-26 07:16:43 -04:00
|
|
|
module Banzai
|
|
|
|
module ReferenceParser
|
2017-12-01 04:21:05 -05:00
|
|
|
class MergeRequestParser < IssuableParser
|
2016-05-26 07:16:43 -04:00
|
|
|
self.reference_type = :merge_request
|
|
|
|
|
2017-12-01 04:21:05 -05:00
|
|
|
def records_for_nodes(nodes)
|
2016-08-24 13:11:48 -04:00
|
|
|
@merge_requests_for_nodes ||= grouped_objects_for_nodes(
|
|
|
|
nodes,
|
2017-04-07 08:40:11 -04:00
|
|
|
MergeRequest.includes(
|
|
|
|
:author,
|
2019-04-07 14:35:16 -04:00
|
|
|
:assignees,
|
2017-04-07 08:40:11 -04:00
|
|
|
{
|
|
|
|
# These associations are primarily used for checking permissions.
|
|
|
|
# Eager loading these ensures we don't end up running dozens of
|
|
|
|
# queries in this process.
|
|
|
|
target_project: [
|
2018-08-16 07:17:41 -04:00
|
|
|
{ namespace: [:owner, :route] },
|
2017-04-07 08:40:11 -04:00
|
|
|
{ group: [:owners, :group_members] },
|
|
|
|
:invited_groups,
|
2017-05-02 12:29:45 -04:00
|
|
|
:project_members,
|
2018-08-16 07:17:41 -04:00
|
|
|
:project_feature,
|
|
|
|
:route
|
2017-04-07 08:40:11 -04:00
|
|
|
]
|
|
|
|
}),
|
2016-08-24 13:11:48 -04:00
|
|
|
self.class.data_attribute
|
|
|
|
)
|
|
|
|
end
|
2016-05-26 07:16:43 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|