summaryrefslogtreecommitdiff
path: root/app/finders/artifacts_finder.rb
blob: 81c5168d7820c64dd58e4cef34e9837a53a8704d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# frozen_string_literal: true

class ArtifactsFinder
  def initialize(project, params = {})
    @project = project
    @params = params
  end

  def execute
    artifacts = @project.job_artifacts

    sort(artifacts)
  end

  private

  def sort_key
    @params[:sort] || 'created_desc'
  end

  def sort(artifacts)
    artifacts.order_by(sort_key)
  end
end