Module: Gitlab::IssuableSorter

Defined in:
lib/gitlab/issuable_sorter.rb

Class Method Summary collapse

Class Method Details

.sort(project, issuables, &sort_key) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/gitlab/issuable_sorter.rb', line 6

def sort(project, issuables, &sort_key)
  grouped_items = issuables.group_by do |issuable|
    if issuable.project.id == project.id
      :project_ref
    elsif issuable.project.namespace_id == project.namespace_id
      :namespace_ref
    else
      :full_ref
    end
  end

  natural_sort_issuables(grouped_items[:project_ref], project) +
    natural_sort_issuables(grouped_items[:namespace_ref], project) +
    natural_sort_issuables(grouped_items[:full_ref], project)
end