diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-25 21:11:05 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-25 21:11:05 +0300 |
commit | 01ae05ffd11edc648e94c44007fced664bc089ea (patch) | |
tree | 37eb766c034959910801f02faa957e63a4cc7227 /app/finders | |
parent | c00ed910738a6db7db12fb9eb67ec318e6dabec5 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/finders')
-rw-r--r-- | app/finders/ci/daily_build_group_report_results_finder.rb | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/app/finders/ci/daily_build_group_report_results_finder.rb b/app/finders/ci/daily_build_group_report_results_finder.rb index 976f3a21b72..9e736c70dda 100644 --- a/app/finders/ci/daily_build_group_report_results_finder.rb +++ b/app/finders/ci/daily_build_group_report_results_finder.rb @@ -11,8 +11,8 @@ # group: integer # coverage: boolean # ref_path: string -# start_date: date -# end_date: date +# start_date: string +# end_date: string # sort: boolean # limit: integer @@ -21,6 +21,8 @@ module Ci include Gitlab::Allowable MAX_ITEMS = 1_000 + REPORT_WINDOW = 90.days + DATE_FORMAT_ALLOWED = '%Y-%m-%d' attr_reader :params, :current_user @@ -62,7 +64,7 @@ module Ci end def by_dates(items) - params[:start_date].present? && params[:end_date].present? ? items.by_dates(params[:start_date], params[:end_date]) : items + params[:start_date].present? && params[:end_date].present? ? items.by_dates(start_date, end_date) : items end def sort(items) @@ -80,6 +82,17 @@ module Ci [params[:limit].to_i, MAX_ITEMS].min end + + def start_date + start_date = Date.strptime(params[:start_date], DATE_FORMAT_ALLOWED) rescue REPORT_WINDOW.ago.to_date + + # The start_date cannot be older than `end_date - 90 days` + [start_date, end_date - REPORT_WINDOW].max + end + + def end_date + Date.strptime(params[:end_date], DATE_FORMAT_ALLOWED) rescue Date.current + end end end |