Commit f3fd21a6 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Merge branch 'move-artifacts-finder-under-ci-namespace' into 'master'

Move ArtifactsFinder under Ci namespace

See merge request gitlab-org/gitlab!28233
parents 0965ca8d 59e02c76
...@@ -22,7 +22,7 @@ class Projects::ArtifactsController < Projects::ApplicationController ...@@ -22,7 +22,7 @@ class Projects::ArtifactsController < Projects::ApplicationController
# issues: https://gitlab.com/gitlab-org/gitlab/issues/32281 # issues: https://gitlab.com/gitlab-org/gitlab/issues/32281
return head :no_content unless Feature.enabled?(:artifacts_management_page, @project) return head :no_content unless Feature.enabled?(:artifacts_management_page, @project)
finder = ArtifactsFinder.new(@project, artifacts_params) finder = Ci::JobArtifactsFinder.new(@project, artifacts_params)
all_artifacts = finder.execute all_artifacts = finder.execute
@artifacts = all_artifacts.page(params[:page]).per(MAX_PER_PAGE) @artifacts = all_artifacts.page(params[:page]).per(MAX_PER_PAGE)
......
# 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
# frozen_string_literal: true
module Ci
class JobArtifactsFinder
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
end
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
describe ArtifactsFinder do describe Ci::JobArtifactsFinder do
let(:project) { create(:project) } let(:project) { create(:project) }
describe '#execute' do describe '#execute' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment