Class: Projects::AutocompleteService

Inherits:
BaseService show all
Includes:
LabelsAsHash
Defined in:
app/services/projects/autocomplete_service.rb

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?

Constructor Details

This class inherits a constructor from BaseService

Instance Method Details

#commands(noteable, type) ⇒ Object


26
27
28
29
30
# File 'app/services/projects/autocomplete_service.rb', line 26

def commands(noteable, type)
  return [] unless noteable

  QuickActions::InterpretService.new(project, current_user).available_commands(noteable)
end

#issuesObject


6
7
8
# File 'app/services/projects/autocomplete_service.rb', line 6

def issues
  IssuesFinder.new(current_user, project_id: project.id, state: 'opened').execute.select([:iid, :title])
end

#labels_as_hash(target) ⇒ Object


36
37
38
# File 'app/services/projects/autocomplete_service.rb', line 36

def labels_as_hash(target)
  super(target, project_id: project.id, include_ancestor_groups: true)
end

#merge_requestsObject


22
23
24
# File 'app/services/projects/autocomplete_service.rb', line 22

def merge_requests
  MergeRequestsFinder.new(current_user, project_id: project.id, state: 'opened').execute.select([:iid, :title])
end

#milestonesObject


10
11
12
13
14
15
16
17
18
19
20
# File 'app/services/projects/autocomplete_service.rb', line 10

def milestones
  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

  MilestonesFinder.new(finder_params).execute.select([:iid, :title])
end

#snippetsObject


32
33
34
# File 'app/services/projects/autocomplete_service.rb', line 32

def snippets
  SnippetsFinder.new(current_user, project: project).execute.select([:id, :title])
end