mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
dashboard next: adds report for user types
This commit is contained in:
@@ -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>
|
||||
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
}
|
||||
|
||||
.dashboard-mini-table {
|
||||
margin-bottom: 1em;
|
||||
|
||||
.table-title {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user