better monthly stats info

This commit is contained in:
Kyle Drake 2016-06-02 20:24:56 -07:00
parent 233b6f758a
commit 2ef7668595

View file

@ -42,11 +42,9 @@ get '/admin/usage' do
month = current_month month = current_month
until month.year == 2015 && month.month == 1 do until month.year == 2016 && month.month == 2 do
stats = DB[
'select sum(views) as views, sum(hits) as hits, sum(bandwidth) as bandwidth from stats where created_at >= ? and created_at < ?', stats = DB["select sum(views) as views, sum(hits) as hits,sum(bandwidth) as bandwidth from daily_site_stats where created_at::text LIKE '#{month.year}-#{month.strftime('%m')}-%'"].first
month,
month.next_month].first
stats.keys.each do |key| stats.keys.each do |key|
stats[key] ||= 0 stats[key] ||= 0