Class: Groups::AutocompleteService

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

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #group, #params

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

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 Groups::BaseService

Instance Method Details

#commands(noteable) ⇒ Object


41
42
43
44
45
# File 'app/services/groups/autocomplete_service.rb', line 41

def commands(noteable)
  return [] unless noteable

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

#issues(confidential_only: false, issue_types: nil) ⇒ Object

rubocop: disable CodeReuse/ActiveRecord


8
9
10
11
12
13
14
15
16
17
# File 'app/services/groups/autocomplete_service.rb', line 8

def issues(confidential_only: false, issue_types: nil)
  finder_params = { group_id: group.id, include_subgroups: true, state: 'opened' }
  finder_params[:confidential] = true if confidential_only.present?
  finder_params[:issue_types] = issue_types if issue_types.present?

  IssuesFinder.new(current_user, finder_params)
    .execute
    .preload(project: :namespace)
    .select(:iid, :title, :project_id)
end

#labels_as_hash(target) ⇒ Object

rubocop: enable CodeReuse/ActiveRecord


37
38
39
# File 'app/services/groups/autocomplete_service.rb', line 37

def labels_as_hash(target)
  super(target, group_id: group.id, only_group_labels: true, include_ancestor_groups: true)
end

#merge_requestsObject

rubocop: disable CodeReuse/ActiveRecord


21
22
23
24
25
26
# File 'app/services/groups/autocomplete_service.rb', line 21

def merge_requests
  MergeRequestsFinder.new(current_user, group_id: group.id, include_subgroups: true, state: 'opened')
    .execute
    .preload(target_project: :namespace)
    .select(:iid, :title, :target_project_id)
end

#milestonesObject

rubocop: disable CodeReuse/ActiveRecord


30
31
32
33
34
# File 'app/services/groups/autocomplete_service.rb', line 30

def milestones
  group_ids = group.self_and_ancestors.public_or_visible_to_user(current_user).pluck(:id)

  MilestonesFinder.new(group_ids: group_ids).execute.select(:iid, :title, :due_date)
end