gitlab-org--gitlab-foss/app/services/projects/autocomplete_service.rb

43 lines
1.2 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
module Projects
class AutocompleteService < BaseService
include LabelsAsHash
def issues
2016-08-12 21:17:18 -04:00
IssuesFinder.new(current_user, project_id: project.id, state: 'opened').execute.select([:iid, :title])
end
def milestones
2017-08-03 13:50:52 -04:00
finder_params = {
project_ids: [@project.id],
state: :active,
order: { due_date: :asc, title: :asc }
}
finder_params[:group_ids] = @project.group.self_and_ancestors.select(:id) if @project.group
2017-08-03 13:50:52 -04:00
MilestonesFinder.new(finder_params).execute.select([:iid, :title])
end
def merge_requests
2016-08-12 21:17:18 -04:00
MergeRequestsFinder.new(current_user, project_id: project.id, state: 'opened').execute.select([:iid, :title])
end
2016-05-03 07:07:06 -04:00
2016-08-12 21:17:18 -04:00
def commands(noteable, type)
return [] unless noteable
2016-08-12 21:17:18 -04:00
QuickActions::InterpretService.new(project, current_user).available_commands(noteable)
end
def snippets
SnippetsFinder.new(current_user, project: project).execute.select([:id, :title])
end
def labels_as_hash(target)
super(target, project_id: project.id, include_ancestor_groups: true)
end
end
end
Projects::AutocompleteService.prepend_if_ee('EE::Projects::AutocompleteService')