2021-10-14 14:44:59 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class Admin::Metrics::Measure::ActiveUsersMeasure < Admin::Metrics::Measure::BaseMeasure
|
|
|
|
def key
|
|
|
|
'active_users'
|
|
|
|
end
|
|
|
|
|
2022-02-22 09:27:08 -05:00
|
|
|
protected
|
|
|
|
|
|
|
|
def perform_total_query
|
2021-10-14 14:44:59 -04:00
|
|
|
activity_tracker.sum(time_period.first, time_period.last)
|
|
|
|
end
|
|
|
|
|
2022-02-22 09:27:08 -05:00
|
|
|
def perform_previous_total_query
|
2021-10-14 14:44:59 -04:00
|
|
|
activity_tracker.sum(previous_time_period.first, previous_time_period.last)
|
|
|
|
end
|
|
|
|
|
2022-02-22 09:27:08 -05:00
|
|
|
def perform_data_query
|
2021-10-14 14:44:59 -04:00
|
|
|
activity_tracker.get(time_period.first, time_period.last).map { |date, value| { date: date.to_time(:utc).iso8601, value: value.to_s } }
|
|
|
|
end
|
|
|
|
|
|
|
|
def activity_tracker
|
|
|
|
@activity_tracker ||= ActivityTracker.new('activity:logins', :unique)
|
|
|
|
end
|
|
|
|
end
|