Add latest changes from gitlab-org/gitlab@master
This commit is contained in:
parent
1c29577b90
commit
3d5d885a6a
|
|
@ -10,7 +10,7 @@ module Resolvers
|
|||
authorize!(object)
|
||||
|
||||
BatchLoader::GraphQL.for(object.id).batch(cache: false) do |ids, loader, args|
|
||||
labels = Label.for_targets(ids, object.class.name).group_by(&:target_id)
|
||||
labels = Label.for_targets(object.class.id_in(ids)).group_by(&:target_id)
|
||||
|
||||
ids.each do |id|
|
||||
loader.call(id, labels[id] || [])
|
||||
|
|
|
|||
|
|
@ -60,11 +60,10 @@ class Label < ApplicationRecord
|
|||
.distinct
|
||||
}
|
||||
|
||||
scope :for_targets, ->(target_ids, targets_type) do
|
||||
scope :for_targets, ->(target_relation) do
|
||||
joins(:label_links)
|
||||
.where(label_links: { target_id: target_ids })
|
||||
.where(label_links: { target_type: targets_type })
|
||||
.select("labels.*, target_id")
|
||||
.merge(LabelLink.where(target: target_relation))
|
||||
.select(arel_table[Arel.star], LabelLink.arel_table[:target_id])
|
||||
.with_preloaded_container
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue