Commit 4328f599 authored by Sean Arnold's avatar Sean Arnold

Move setting of parent to issuable finder

- use before_all in spec
parent a93d7dae
...@@ -204,8 +204,30 @@ class IssuableFinder ...@@ -204,8 +204,30 @@ class IssuableFinder
end end
end end
def parent=(obj)
@parent = obj
end
def parent_param=(obj)
@parent = obj
params[parent_param] = parent if parent
end
def parent_param
case parent
when Project
:project_id
when Group
:group_id
else
raise "Unexpected parent: #{parent.class}"
end
end
private private
attr_reader :parent
def not_params def not_params
strong_memoize(:not_params) do strong_memoize(:not_params) do
params_class.new(params[:not].dup, current_user, klass).tap do |not_params| params_class.new(params[:not].dup, current_user, klass).tap do |not_params|
......
...@@ -7,21 +7,8 @@ module Resolvers ...@@ -7,21 +7,8 @@ module Resolvers
type Types::IssueStatusCountsType, null: true type Types::IssueStatusCountsType, null: true
def continue_issue_resolve(parent, finder, **args) def continue_issue_resolve(parent, finder, **args)
finder.params[parent_param(parent)] = parent if parent finder.parent_param = parent
apply_lookahead(Gitlab::IssuablesCountForState.new(finder, parent)) apply_lookahead(Gitlab::IssuablesCountForState.new(finder, parent))
end end
private
def parent_param(parent)
case parent
when Project
:project_id
when Group
:group_id
else
raise "Unexpected type of parent: #{parent.class}. Must be Project or Group"
end
end
end end
end end
...@@ -15,6 +15,7 @@ module Gitlab ...@@ -15,6 +15,7 @@ module Gitlab
def batching_find_all(&with_query) def batching_find_all(&with_query)
if issuable_finder.params.keys == ['iids'] if issuable_finder.params.keys == ['iids']
issuable_finder.parent = parent
batch_load_issuables(issuable_finder.params[:iids], with_query) batch_load_issuables(issuable_finder.params[:iids], with_query)
else else
post_process(find_all, with_query) post_process(find_all, with_query)
...@@ -22,24 +23,12 @@ module Gitlab ...@@ -22,24 +23,12 @@ module Gitlab
end end
def find_all def find_all
issuable_finder.params[parent_param] = parent if parent issuable_finder.parent_param = parent if parent
issuable_finder.execute issuable_finder.execute
end end
private private
def parent_param
case parent
when Project
:project_id
when Group
:group_id
else
raise "Unexpected parent: #{parent.class}"
end
end
def post_process(query, with_query) def post_process(query, with_query)
if with_query if with_query
with_query.call(query) with_query.call(query)
...@@ -56,7 +45,7 @@ module Gitlab ...@@ -56,7 +45,7 @@ module Gitlab
return if parent.nil? return if parent.nil?
BatchLoader::GraphQL BatchLoader::GraphQL
.for([parent_param, iid.to_s]) .for([issuable_finder.parent_param, iid.to_s])
.batch(key: batch_key) do |params, loader, args| .batch(key: batch_key) do |params, loader, args|
batch_key = args[:key] batch_key = args[:key]
user = batch_key.current_user user = batch_key.current_user
......
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