mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-22 19:16:39 +10:00
21 lines
490 B
Ruby
21 lines
490 B
Ruby
class HistoricalData < ActiveRecord::Base
|
|
validate :date, presence: true
|
|
|
|
# HistoricalData.during((Date.today - 1.year)..Date.today).average(:active_user_count)
|
|
scope :during, ->(range) { where(date: range) }
|
|
|
|
class << self
|
|
def track!
|
|
create!(
|
|
date: Date.today,
|
|
active_user_count: User.active.count
|
|
)
|
|
end
|
|
|
|
# HistoricalData.at(Date.new(2014, 1, 1)).active_user_count
|
|
def at(date)
|
|
find_by(date: date)
|
|
end
|
|
end
|
|
end
|