dashboard next: adds report for user types

This commit is contained in:
Joffrey JAFFEUX
2018-04-16 13:03:43 +02:00
committed by GitHub
parent 9353ae4b5d
commit 06b6c805d5
5 changed files with 57 additions and 0 deletions

View File

@@ -26,6 +26,7 @@
<div class="section-columns">
<div class="section-column">
{{dashboard-mini-table dataSourceName="users_by_types"}}
{{dashboard-mini-table dataSourceName="users_by_trust_level"}}
</div>

View File

@@ -34,6 +34,8 @@
}
.dashboard-mini-table {
margin-bottom: 1em;
.table-title {
align-items: center;
display: flex;

View File

@@ -243,4 +243,22 @@ class Report
.group(:user_agent).sum(:count)
.map { |ua, count| { x: ua, y: count } }
end
def self.report_users_by_types(report)
report.data = []
label = Proc.new { |key| I18n.t("reports.users_by_types.xaxis_labels.#{key}") }
admins = User.real.where(admin: true).count
report.data << { x: label.call("admin"), y: admins } if admins > 0
moderators = User.real.where(moderator: true).count
report.data << { x: label.call("moderator"), y: moderators } if moderators > 0
suspended = User.suspended.count
report.data << { x: label.call("suspended"), y: suspended } if suspended > 0
silenced = User.silenced.count
report.data << { x: label.call("silenced"), y: silenced } if silenced > 0
end
end