Welcome to mirror list, hosted at ThFree Co, Russian Federation.

sort_options.rb « search « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3395c34d171f45a9ae36103227c28c4afda18643 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# frozen_string_literal: true

module Gitlab
  module Search
    module SortOptions
      def sort_and_direction(order_by, sort)
        # Due to different uses of sort param in web vs. API requests we prefer
        # order_by when present
        case [order_by, sort]
        when %w[created_at asc], [nil, 'created_asc']
          :created_at_asc
        when %w[created_at desc], [nil, 'created_desc']
          :created_at_desc
        else
          :unknown
        end
      end
      module_function :sort_and_direction # rubocop: disable Style/AccessModifierDeclarations
    end
  end
end