Class: Gitlab::Usage::Metrics::Aggregates::Aggregate

Inherits:
Object
  • Object
show all
Includes:
TimeFrame
Defined in:
lib/gitlab/usage/metrics/aggregates/aggregate.rb

Constant Summary

Constants included from TimeFrame

TimeFrame::ALL_TIME_TIME_FRAME_NAME, TimeFrame::SEVEN_DAYS_TIME_FRAME_NAME, TimeFrame::TWENTY_EIGHT_DAYS_TIME_FRAME_NAME

Instance Method Summary collapse

Methods included from TimeFrame

#monthly_time_range, #monthly_time_range_db_params, #weekly_time_range

Constructor Details

#initialize(recorded_at) ⇒ Aggregate

Returns a new instance of Aggregate.


10
11
12
13
# File 'lib/gitlab/usage/metrics/aggregates/aggregate.rb', line 10

def initialize(recorded_at)
  @aggregated_metrics = load_metrics(AGGREGATED_METRICS_PATH)
  @recorded_at = recorded_at
end

Instance Method Details

#all_time_dataObject


15
16
17
# File 'lib/gitlab/usage/metrics/aggregates/aggregate.rb', line 15

def all_time_data
  aggregated_metrics_data(start_date: nil, end_date: nil, time_frame: Gitlab::Usage::TimeFrame::ALL_TIME_TIME_FRAME_NAME)
end

#monthly_dataObject


19
20
21
# File 'lib/gitlab/usage/metrics/aggregates/aggregate.rb', line 19

def monthly_data
  aggregated_metrics_data(**monthly_time_range.merge(time_frame: Gitlab::Usage::TimeFrame::TWENTY_EIGHT_DAYS_TIME_FRAME_NAME))
end

#weekly_dataObject


23
24
25
# File 'lib/gitlab/usage/metrics/aggregates/aggregate.rb', line 23

def weekly_data
  aggregated_metrics_data(**weekly_time_range.merge(time_frame: Gitlab::Usage::TimeFrame::SEVEN_DAYS_TIME_FRAME_NAME))
end