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)
|
authorize!(object)
|
||||||
|
|
||||||
BatchLoader::GraphQL.for(object.id).batch(cache: false) do |ids, loader, args|
|
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|
|
ids.each do |id|
|
||||||
loader.call(id, labels[id] || [])
|
loader.call(id, labels[id] || [])
|
||||||
|
|
|
||||||
|
|
@ -60,11 +60,10 @@ class Label < ApplicationRecord
|
||||||
.distinct
|
.distinct
|
||||||
}
|
}
|
||||||
|
|
||||||
scope :for_targets, ->(target_ids, targets_type) do
|
scope :for_targets, ->(target_relation) do
|
||||||
joins(:label_links)
|
joins(:label_links)
|
||||||
.where(label_links: { target_id: target_ids })
|
.merge(LabelLink.where(target: target_relation))
|
||||||
.where(label_links: { target_type: targets_type })
|
.select(arel_table[Arel.star], LabelLink.arel_table[:target_id])
|
||||||
.select("labels.*, target_id")
|
|
||||||
.with_preloaded_container
|
.with_preloaded_container
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue