show bandwidth on dashboard, fix extra stats one_to_many, clarify stats retainent and fix typo

This commit is contained in:
Kyle Drake 2025-02-04 19:57:28 -06:00
parent 2dd1f55119
commit a81a708be5
5 changed files with 29 additions and 11 deletions

View file

@ -205,8 +205,6 @@ class Site < Sequel::Model
one_to_many :reports
one_to_many :reportings, key: :reporting_site_id, class: :Report
one_to_many :stats
one_to_many :events
one_to_many :site_changes
@ -1903,6 +1901,16 @@ class Site < Sequel::Model
true
end
def maximum_monthly_bandwidth
PLAN_FEATURES[(parent? ? self : parent).plan_type.to_sym][:bandwidth].to_i
end
def monthly_bandwidth_used
stat = stats_dataset.order(:created_at.desc).select(:bandwidth).first
return 0 if stat.nil?
stat[:bandwidth]
end
private
def store_file(path, uploaded, opts={})