Welcome to mirror list, hosted at ThFree Co, Russian Federation.

time_frame.rb « usage « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 966a087ee0799e496270c1d62b311b537e5b2d01 (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
# frozen_string_literal: true

module Gitlab
  module Usage
    module TimeFrame
      ALL_TIME_TIME_FRAME_NAME = "all"
      SEVEN_DAYS_TIME_FRAME_NAME = "7d"
      TWENTY_EIGHT_DAYS_TIME_FRAME_NAME = "28d"

      def weekly_time_range
        { start_date: 7.days.ago.to_date, end_date: Date.current }
      end

      def monthly_time_range
        { start_date: 4.weeks.ago.to_date, end_date: Date.current }
      end

      # This time range is skewed for batch counter performance.
      # See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/42972
      def monthly_time_range_db_params(column: :created_at)
        { column => 30.days.ago..2.days.ago }
      end
    end
  end
end