2020-09-03 12:08:47 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2021-06-08 15:10:00 +00:00
|
|
|
module BoardItemFilterable
|
2020-09-03 12:08:47 +00:00
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2021-06-08 15:10:00 +00:00
|
|
|
def item_filters(args)
|
2020-09-03 12:08:47 +00:00
|
|
|
filters = args.to_h
|
2021-04-19 09:09:30 +00:00
|
|
|
|
2020-09-03 12:08:47 +00:00
|
|
|
set_filter_values(filters)
|
|
|
|
|
|
|
|
if filters[:not]
|
|
|
|
set_filter_values(filters[:not])
|
|
|
|
end
|
|
|
|
|
|
|
|
filters
|
|
|
|
end
|
|
|
|
|
|
|
|
def set_filter_values(filters)
|
2021-04-13 18:11:28 +00:00
|
|
|
filter_by_assignee(filters)
|
|
|
|
end
|
|
|
|
|
|
|
|
def filter_by_assignee(filters)
|
|
|
|
if filters[:assignee_username] && filters[:assignee_wildcard_id]
|
|
|
|
raise ::Gitlab::Graphql::Errors::ArgumentError, 'Incompatible arguments: assigneeUsername, assigneeWildcardId.'
|
|
|
|
end
|
|
|
|
|
|
|
|
if filters[:assignee_wildcard_id]
|
|
|
|
filters[:assignee_id] = filters.delete(:assignee_wildcard_id)
|
|
|
|
end
|
2020-09-03 12:08:47 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-06-08 15:10:00 +00:00
|
|
|
::BoardItemFilterable.prepend_mod_with('Resolvers::BoardItemFilterable')
|