debian-mirror-gitlab/app/services/projects/autocomplete_service.rb

41 lines
1.1 KiB
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2015-04-26 12:48:37 +05:30
module Projects
class AutocompleteService < BaseService
2018-12-05 23:21:45 +05:30
include LabelsAsHash
2016-06-02 11:05:42 +05:30
def issues
2016-09-13 17:45:13 +05:30
IssuesFinder.new(current_user, project_id: project.id, state: 'opened').execute.select([:iid, :title])
2015-04-26 12:48:37 +05:30
end
2016-06-02 11:05:42 +05:30
def milestones
2017-09-10 17:25:29 +05:30
finder_params = {
project_ids: [@project.id],
state: :active,
order: { due_date: :asc, title: :asc }
}
2018-11-08 19:23:39 +05:30
finder_params[:group_ids] = @project.group.self_and_ancestors_ids if @project.group
2017-09-10 17:25:29 +05:30
MilestonesFinder.new(finder_params).execute.select([:iid, :title])
2015-04-26 12:48:37 +05:30
end
def merge_requests
2016-09-13 17:45:13 +05:30
MergeRequestsFinder.new(current_user, project_id: project.id, state: 'opened').execute.select([:iid, :title])
2015-04-26 12:48:37 +05:30
end
2016-06-22 15:30:34 +05:30
2016-09-13 17:45:13 +05:30
def commands(noteable, type)
2018-11-20 20:47:30 +05:30
return [] unless noteable
2016-09-13 17:45:13 +05:30
2018-03-27 19:54:05 +05:30
QuickActions::InterpretService.new(project, current_user).available_commands(noteable)
2016-09-13 17:45:13 +05:30
end
2018-12-05 23:21:45 +05:30
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
2015-04-26 12:48:37 +05:30
end
end