2018-07-17 16:50:37 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-01-23 01:51:35 +00:00
|
|
|
module Projects
|
|
|
|
class AutocompleteService < BaseService
|
2018-09-28 13:47:58 +00:00
|
|
|
include LabelsAsHash
|
2015-01-23 01:51:35 +00:00
|
|
|
def issues
|
2016-08-13 01:17:18 +00:00
|
|
|
IssuesFinder.new(current_user, project_id: project.id, state: 'opened').execute.select([:iid, :title])
|
2015-01-23 01:51:35 +00:00
|
|
|
end
|
|
|
|
|
2016-04-05 02:37:50 +00:00
|
|
|
def milestones
|
2017-08-03 17:50:52 +00:00
|
|
|
finder_params = {
|
|
|
|
project_ids: [@project.id],
|
|
|
|
state: :active,
|
|
|
|
order: { due_date: :asc, title: :asc }
|
|
|
|
}
|
|
|
|
|
2019-01-11 14:58:18 +00:00
|
|
|
finder_params[:group_ids] = @project.group.self_and_ancestors.select(:id) if @project.group
|
2017-08-03 17:50:52 +00:00
|
|
|
|
2021-03-10 12:09:14 +00:00
|
|
|
MilestonesFinder.new(finder_params).execute.select([:iid, :title, :due_date])
|
2016-04-05 02:37:50 +00:00
|
|
|
end
|
|
|
|
|
2015-01-23 01:51:35 +00:00
|
|
|
def merge_requests
|
2016-08-13 01:17:18 +00:00
|
|
|
MergeRequestsFinder.new(current_user, project_id: project.id, state: 'opened').execute.select([:iid, :title])
|
2015-01-23 01:51:35 +00:00
|
|
|
end
|
2016-05-03 11:07:06 +00:00
|
|
|
|
2016-08-13 01:17:18 +00:00
|
|
|
def commands(noteable, type)
|
2018-07-21 08:11:07 +00:00
|
|
|
return [] unless noteable
|
2016-08-13 01:17:18 +00:00
|
|
|
|
2018-02-23 14:23:09 +00:00
|
|
|
QuickActions::InterpretService.new(project, current_user).available_commands(noteable)
|
2016-06-30 15:34:19 +00:00
|
|
|
end
|
2018-09-28 13:47:58 +00:00
|
|
|
|
2018-10-05 09:42:38 +00:00
|
|
|
def snippets
|
|
|
|
SnippetsFinder.new(current_user, project: project).execute.select([:id, :title])
|
|
|
|
end
|
|
|
|
|
2022-01-25 21:15:18 +00:00
|
|
|
def contacts
|
|
|
|
Crm::ContactsFinder.new(current_user, group: project.group).execute
|
|
|
|
.select([:id, :email, :first_name, :last_name])
|
|
|
|
end
|
|
|
|
|
2018-09-28 13:47:58 +00:00
|
|
|
def labels_as_hash(target)
|
|
|
|
super(target, project_id: project.id, include_ancestor_groups: true)
|
|
|
|
end
|
2015-01-23 01:51:35 +00:00
|
|
|
end
|
|
|
|
end
|
2019-09-13 13:26:31 +00:00
|
|
|
|
2021-05-11 21:10:21 +00:00
|
|
|
Projects::AutocompleteService.prepend_mod_with('Projects::AutocompleteService')
|