2019-07-07 11:18:12 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module API
|
|
|
|
module Helpers
|
|
|
|
module IssuesHelpers
|
2019-09-04 21:01:54 +05:30
|
|
|
extend Grape::API::Helpers
|
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
params :negatable_issue_filter_params_ee do
|
|
|
|
end
|
|
|
|
|
2019-09-04 21:01:54 +05:30
|
|
|
params :optional_issue_params_ee do
|
|
|
|
end
|
|
|
|
|
|
|
|
params :optional_issues_params_ee do
|
|
|
|
end
|
|
|
|
|
2019-12-04 20:38:33 +05:30
|
|
|
params :optional_issue_not_params_ee do
|
|
|
|
end
|
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
def self.update_params_at_least_one_of
|
|
|
|
[
|
|
|
|
:assignee_id,
|
|
|
|
:assignee_ids,
|
|
|
|
:confidential,
|
|
|
|
:created_at,
|
|
|
|
:description,
|
|
|
|
:discussion_locked,
|
|
|
|
:due_date,
|
|
|
|
:labels,
|
2020-06-23 00:09:42 +05:30
|
|
|
:add_labels,
|
|
|
|
:remove_labels,
|
2019-07-07 11:18:12 +05:30
|
|
|
:milestone_id,
|
|
|
|
:state_event,
|
|
|
|
:title
|
|
|
|
]
|
|
|
|
end
|
2019-09-04 21:01:54 +05:30
|
|
|
|
2019-12-04 20:38:33 +05:30
|
|
|
def self.sort_options
|
|
|
|
%w[created_at updated_at priority due_date relative_position label_priority milestone_due popularity]
|
|
|
|
end
|
|
|
|
|
2019-09-04 21:01:54 +05:30
|
|
|
def issue_finder(args = {})
|
|
|
|
args = declared_params.merge(args)
|
|
|
|
|
|
|
|
args.delete(:id)
|
2019-12-04 20:38:33 +05:30
|
|
|
args[:not] ||= {}
|
2019-09-04 21:01:54 +05:30
|
|
|
args[:milestone_title] ||= args.delete(:milestone)
|
2019-12-04 20:38:33 +05:30
|
|
|
args[:not][:milestone_title] ||= args[:not]&.delete(:milestone)
|
2019-09-04 21:01:54 +05:30
|
|
|
args[:label_name] ||= args.delete(:labels)
|
2019-12-04 20:38:33 +05:30
|
|
|
args[:not][:label_name] ||= args[:not]&.delete(:labels)
|
2019-09-04 21:01:54 +05:30
|
|
|
args[:scope] = args[:scope].underscore if args[:scope]
|
2019-12-04 20:38:33 +05:30
|
|
|
args[:sort] = "#{args[:order_by]}_#{args[:sort]}"
|
2019-09-04 21:01:54 +05:30
|
|
|
|
|
|
|
IssuesFinder.new(current_user, args)
|
|
|
|
end
|
|
|
|
|
|
|
|
def find_issues(args = {})
|
|
|
|
finder = issue_finder(args)
|
2019-12-04 20:38:33 +05:30
|
|
|
finder.execute.with_api_entity_associations
|
2019-09-04 21:01:54 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def issues_statistics(args = {})
|
|
|
|
finder = issue_finder(args)
|
|
|
|
counter = Gitlab::IssuablesCountForState.new(finder)
|
|
|
|
|
|
|
|
{
|
|
|
|
statistics: {
|
|
|
|
counts: {
|
|
|
|
all: counter[:all],
|
|
|
|
closed: counter[:closed],
|
|
|
|
opened: counter[:opened]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
2019-07-07 11:18:12 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-12-04 20:38:33 +05:30
|
|
|
|
|
|
|
API::Helpers::IssuesHelpers.prepend_if_ee('EE::API::Helpers::IssuesHelpers')
|