Module: Gitlab::Usage::TimeFrame

Constant Summary collapse

ALL_TIME_TIME_FRAME_NAME =
"all"
SEVEN_DAYS_TIME_FRAME_NAME =
"7d"
TWENTY_EIGHT_DAYS_TIME_FRAME_NAME =
"28d"
DEFAULT_TIMESTAMP_COLUMN =
:created_at

Instance Method Summary collapse

Instance Method Details

#monthly_time_rangeObject



15
16
17
# File 'lib/gitlab/usage/time_frame.rb', line 15

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

#monthly_time_range_db_params(column: nil) ⇒ Object

This time range is skewed for batch counter performance. See gitlab.com/gitlab-org/gitlab/-/merge_requests/42972



21
22
23
# File 'lib/gitlab/usage/time_frame.rb', line 21

def monthly_time_range_db_params(column: nil)
  { (column || DEFAULT_TIMESTAMP_COLUMN) => 30.days.ago..2.days.ago }
end

#weekly_time_rangeObject



11
12
13
# File 'lib/gitlab/usage/time_frame.rb', line 11

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

#weekly_time_range_db_params(column: nil) ⇒ Object



25
26
27
# File 'lib/gitlab/usage/time_frame.rb', line 25

def weekly_time_range_db_params(column: nil)
  { (column || DEFAULT_TIMESTAMP_COLUMN) => 9.days.ago..2.days.ago }
end