25 lines
359 B
Ruby
25 lines
359 B
Ruby
|
# 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
|