Skip to content

Commit

Permalink
Add 'all' column to admin dashboard counts
Browse files Browse the repository at this point in the history
  • Loading branch information
nlalonde committed Mar 21, 2013
1 parent 38415f2 commit 40962c8
Show file tree
Hide file tree
Showing 17 changed files with 1,323 additions and 1,192 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@
</div>
{{/if}}


<div class="dashboard-stats total-users">
{{i18n admin.dashboard.total_users}}: <strong>{{#unless loading}}{{ totalUsers }}{{/unless}}</strong><br/>
</div>

<div class="dashboard-stats trust-levels">
<table class="table table-condensed table-hover">
<thead>
Expand Down Expand Up @@ -94,6 +89,7 @@
<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}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
<td class="value">{{valueAtDaysAgo data 1}}</td>
<td class="value">{{valueAtDaysAgo data 7}}</td>
<td class="value">{{valueAtDaysAgo data 30}}</td>
<td class="value">{{total}}</td>
</tr>
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
<td class="value">{{valueAtDaysAgo data 1}}</td>
<td class="value">{{sumLast data 7}}</td>
<td class="value">{{sumLast data 30}}</td>
<td class="value">{{total}}</td>
</tr>
1 change: 0 additions & 1 deletion app/models/admin_dashboard_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ def self.fetch
def as_json
@json ||= {
reports: REPORTS.map { |type| Report.find(type) },
total_users: User.count,
problems: [rails_env_check, host_names_check, gc_checks].compact
}.merge(
SiteSetting.version_checks? ? {version_check: DiscourseUpdates.check_version} : {}
Expand Down
12 changes: 10 additions & 2 deletions app/models/report.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
class Report

attr_accessor :type, :data
attr_accessor :type, :data, :total

def initialize(type)
@type = type
@data = nil
@total = nil
end

def as_json
Expand All @@ -13,7 +14,8 @@ def as_json
title: I18n.t("reports.#{self.type}.title"),
xaxis: I18n.t("reports.#{self.type}.xaxis"),
yaxis: I18n.t("reports.#{self.type}.yaxis"),
data: self.data
data: self.data,
total: self.total
}
end

Expand All @@ -39,20 +41,23 @@ def self.report_signups(report)
User.count_by_signup_date(30.days.ago).each do |date, count|
report.data << {x: date, y: count}
end
report.total = User.count
end

def self.report_topics(report)
report.data = []
Topic.count_per_day(30.days.ago).each do |date, count|
report.data << {x: date, y: count}
end
report.total = Topic.count
end

def self.report_posts(report)
report.data = []
Post.count_per_day(30.days.ago).each do |date, count|
report.data << {x: date, y: count}
end
report.total = Post.count
end

def self.report_flags(report)
Expand All @@ -62,6 +67,7 @@ def self.report_flags(report)
report.data << {x: i.days.ago.to_date.to_s, y: count}
end
end
report.total = PostAction.where(post_action_type_id: PostActionType.flag_types.values).count
end

def self.report_users_by_trust_level(report)
Expand All @@ -76,13 +82,15 @@ def self.report_likes(report)
PostAction.count_likes_per_day(30.days.ago).each do |date, count|
report.data << {x: date, y: count}
end
report.total = PostAction.where(post_action_type_id: PostActionType.types[:like]).count
end

def self.report_emails(report)
report.data = []
EmailLog.count_per_day(30.days.ago).each do |date, count|
report.data << {x: date, y: count}
end
report.total = EmailLog.count
end

end
1 change: 0 additions & 1 deletion config/locales/client.cs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,6 @@ cs:
please_upgrade: "Prosím aktualizujte!"
latest_version: "Poslední verze"
update_often: 'Prosím aktualizujte často!'
total_users: "Celkem uživatelů"
moderator_short: "mod"

reports:
Expand Down
2 changes: 1 addition & 1 deletion config/locales/client.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,6 @@ en:
installed_version: "Installed"
latest_version: "Latest"
update_often: 'Please update often!'
total_users: "Total Users"
moderator_short: "mod"
problems_found: "Some problems have been found with your installation of Discourse:"

Expand All @@ -712,6 +711,7 @@ en:
all_time: "All Time"
7_days_ago: "7 Days Ago"
30_days_ago: "30 Days Ago"
all: "All"

commits:
latest_changes: "Latest changes."
Expand Down
1 change: 0 additions & 1 deletion config/locales/client.fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,6 @@ fr:
installed_version: "Version installée"
latest_version: "Dernière version"
update_often: "Merci de mettre à jour régulièrement !"
total_users: "Total d'utilisateurs"
moderator_short: "mod"
problems_found: "Quelques problèmes ont été trouvés dans votre installation de Discourse :"

Expand Down
Loading

0 comments on commit 40962c8

Please sign in to comment.