debian-mirror-gitlab/app/finders/ci/daily_build_group_report_results_finder.rb

42 lines
902 B
Ruby
Raw Normal View History

2020-05-24 23:13:21 +05:30
# frozen_string_literal: true
module Ci
class DailyBuildGroupReportResultsFinder
include Gitlab::Allowable
def initialize(current_user:, project:, ref_path:, start_date:, end_date:, limit: nil)
@current_user = current_user
@project = project
@ref_path = ref_path
@start_date = start_date
@end_date = end_date
@limit = limit
end
def execute
2020-06-23 00:09:42 +05:30
return none unless can?(current_user, :read_build_report_results, project)
2020-05-24 23:13:21 +05:30
Ci::DailyBuildGroupReportResult.recent_results(
2020-06-23 00:09:42 +05:30
query_params,
limit: limit
2020-05-24 23:13:21 +05:30
)
end
private
2020-06-23 00:09:42 +05:30
attr_reader :current_user, :project, :ref_path, :start_date, :end_date, :limit
def query_params
{
project_id: project,
ref_path: ref_path,
date: start_date..end_date
}
end
2020-05-24 23:13:21 +05:30
def none
Ci::DailyBuildGroupReportResult.none
end
end
end