summaryrefslogtreecommitdiff
path: root/app/finders/ci/daily_build_group_report_results_finder.rb
blob: 3c3c24c1479f825bd0d5876b153a85689192ed91 (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
25
26
27
28
29
30
31
32
33
34
35
36
37
# 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
      return none unless can?(current_user, :download_code, project)

      Ci::DailyBuildGroupReportResult.recent_results(
        {
          project_id: project,
          ref_path: ref_path,
          date: start_date..end_date
        },
        limit: @limit
      )
    end

    private

    attr_reader :current_user, :project, :ref_path, :start_date, :end_date

    def none
      Ci::DailyBuildGroupReportResult.none
    end
  end
end