FEATURE: dashboard stats for application traffic

This commit is contained in:
Sam 2015-02-05 11:18:11 +11:00
parent 3b68214210
commit c9adfa65a0
5 changed files with 82 additions and 1 deletions

View file

@ -62,6 +62,27 @@
</table>
</div>
<div class="dashboard-stats">
<table class="table table-condensed table-hover">
<thead>
<tr>
<th class="title" title="{{i18n 'admin.dashboard.traffic'}}">{{i18n 'admin.dashboard.traffic_short'}}</th>
<th>{{i18n 'admin.dashboard.reports.today'}}</th>
<th>{{i18n 'admin.dashboard.reports.yesterday'}}</th>
<th>{{i18n 'admin.dashboard.reports.last_7_days'}}</th>
<th>{{i18n 'admin.dashboard.reports.last_30_days'}}</th>
<th>{{i18n 'admin.dashboard.reports.all'}}</th>
</tr>
</thead>
{{#unless loading}}
{{ render 'admin_report_counts' anon_reqs }}
{{ render 'admin_report_counts' logged_in_reqs }}
{{ render 'admin_report_counts' crawler_reqs}}
{{ render 'admin_report_counts' total_reqs}}
{{/unless}}
</table>
</div>
<div class="dashboard-stats">
<table class="table table-condensed table-hover">
<thead>

View file

@ -16,7 +16,11 @@ class AdminDashboardData
'system_private_messages',
'moderator_warning_private_messages',
'notify_moderators_private_messages',
'notify_user_private_messages'
'notify_user_private_messages',
'anon_reqs',
'crawler_reqs',
'logged_in_reqs',
'total_reqs'
]
def problems

View file

@ -45,6 +45,44 @@ class Report
report
end
def self.req_report(report, filter=nil)
data = ApplicationRequest.all
if mapped = ApplicationRequest.req_types[filter]
data = data.where(req_type: mapped)
end
filtered_results = data.where('date >= ? AND date <= ?', report.start_date.to_date, report.end_date.to_date)
report.data = []
filtered_results.group(:date)
.sum(:count)
.each do |date, count|
report.data << {x: date, y: count}
end
report.total = data.sum(:count)
report.prev30Days = filtered_results.sum(:count)
end
def self.report_anon_reqs(report)
req_report(report, :anon)
end
def self.report_crawler_reqs(report)
req_report(report, :crawler)
end
def self.report_logged_in_reqs(report)
req_report(report, :logged_in)
end
def self.report_total_reqs(report)
req_report(report)
end
def self.report_visits(report)
basic_report_about report, UserVisit, :by_day, report.start_date, report.end_date
end

View file

@ -1535,6 +1535,8 @@ en:
space_free: "{{size}} free"
uploads: "uploads"
backups: "backups"
traffic_short: "Application Traffic"
traffic: "Application web requests"
reports:
today: "Today"

View file

@ -588,6 +588,22 @@ en:
title: "Top Referred Topics"
xaxis: "Topic"
num_clicks: "Clicks"
anon_reqs:
title: "Anonymous"
xaxis: "Day"
yaxis: "Anonymous application requests"
logged_in_reqs:
title: "Logged In"
xaxis: "Day"
yaxis: "Logged In application requests"
crawler_reqs:
title: "Crawler"
xaxis: "Day"
yaxis: "Crawler application requests"
total_reqs:
title: "Total"
xaxis: "Day"
yaxis: "Total application requests"
dashboard:
rails_env_warning: "Your server is running in %{env} mode."