debian-mirror-gitlab/lib/api/helpers/issues_helpers.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

92 lines
2.2 KiB
Ruby
Raw Normal View History

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
2021-04-17 20:07:23 +05:30
params :issues_stats_params_ee do
2019-12-04 20:38:33 +05:30
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,
2021-06-08 01:23:25 +05:30
:title,
:issue_type
2019-07-07 11:18:12 +05:30
]
end
2019-09-04 21:01:54 +05:30
2019-12-04 20:38:33 +05:30
def self.sort_options
2021-11-11 11:23:49 +05:30
%w[
created_at
due_date
label_priority
milestone_due
popularity
priority
relative_position
title
updated_at
]
2019-12-04 20:38:33 +05:30
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)
2021-11-11 11:23:49 +05:30
args[:milestone_wildcard_id] ||= args.delete(:milestone_id)
args[:not][:milestone_title] ||= args[:not].delete(:milestone)
args[:not][:milestone_wildcard_id] ||= args[:not].delete(:milestone_id)
2019-09-04 21:01:54 +05:30
args[:label_name] ||= args.delete(:labels)
2021-11-11 11:23:49 +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]}"
2021-06-08 01:23:25 +05:30
args[:issue_types] ||= args.delete(:issue_type)
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
2021-06-08 01:23:25 +05:30
API::Helpers::IssuesHelpers.prepend_mod_with('API::Helpers::IssuesHelpers')