Show current user count for now, not at different points in time
This commit is contained in:
parent
3ba567eba0
commit
8983df9856
|
@ -26,6 +26,7 @@ Discourse.AdminDashboardRoute = Discourse.Route.extend({
|
|||
d.reports.each(function(report){
|
||||
c.set(report.type, Discourse.Report.create(report));
|
||||
});
|
||||
c.set('totalUsers', d.total_users);
|
||||
c.set('loading', false);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -38,6 +38,15 @@
|
|||
</p>
|
||||
</div>
|
||||
|
||||
<div class="dashboard-stats totals">
|
||||
<table class="table table-condensed table-hover">
|
||||
<tr>
|
||||
<td class="title">{{i18n admin.dashboard.total_users}}</td>
|
||||
<td class="value">{{#unless loading}}{{ totalUsers }}{{/unless}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="dashboard-stats">
|
||||
<table class="table table-condensed table-hover">
|
||||
<thead>
|
||||
|
@ -70,7 +79,6 @@
|
|||
</tr>
|
||||
</thead>
|
||||
{{#unless loading}}
|
||||
{{ render 'admin_report_total_users' total_users }}
|
||||
{{ render 'admin_report_visits' visits }}
|
||||
{{/unless}}
|
||||
</table>
|
||||
|
|
|
@ -324,6 +324,14 @@ table {
|
|||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
&.totals {
|
||||
width: 160px;
|
||||
|
||||
table tr:first-child td {
|
||||
border-top: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,8 @@ class Admin::DashboardController < Admin::AdminController
|
|||
|
||||
def index
|
||||
render_json_dump({
|
||||
reports: ['visits', 'signups', 'topics', 'posts', 'total_users', 'flags'].map { |type| Report.find(type) }
|
||||
reports: ['visits', 'signups', 'topics', 'posts', 'flags'].map { |type| Report.find(type) },
|
||||
total_users: User.count
|
||||
}.merge(
|
||||
SiteSetting.version_checks? ? {version_check: DiscourseUpdates.check_version} : {}
|
||||
))
|
||||
|
|
|
@ -69,17 +69,6 @@ class Report
|
|||
end
|
||||
end
|
||||
|
||||
def self.report_total_users(report)
|
||||
report.data = []
|
||||
fetch report do
|
||||
(0..30).to_a.reverse.each do |i|
|
||||
if (count = User.where('created_at < ?', i.days.ago).count) > 0
|
||||
report.data << {x: i.days.ago.to_date.to_s, y: count}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.report_flags(report)
|
||||
report.data = []
|
||||
fetch report do
|
||||
|
|
|
@ -690,6 +690,7 @@ en:
|
|||
please_upgrade: "Please upgrade!"
|
||||
latest_version: "Latest version"
|
||||
update_often: 'Please update often!'
|
||||
total_users: "Total Users"
|
||||
|
||||
reports:
|
||||
today: "Today"
|
||||
|
|
|
@ -58,29 +58,6 @@ describe Report do
|
|||
end
|
||||
end
|
||||
|
||||
describe "total_users report" do
|
||||
let(:report) { Report.find("total_users", cache: false) }
|
||||
|
||||
context "no total_users" do
|
||||
it 'returns an empty report' do
|
||||
report.data.should be_blank
|
||||
end
|
||||
end
|
||||
|
||||
context "with users" do
|
||||
before do
|
||||
Fabricate(:user, created_at: 25.hours.ago)
|
||||
Fabricate(:user, created_at: 1.hours.ago)
|
||||
Fabricate(:user, created_at: 1.hours.ago)
|
||||
end
|
||||
|
||||
it 'returns correct data' do
|
||||
report.data[0][:y].should == 1
|
||||
report.data[1][:y].should == 3
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#fetch' do
|
||||
context 'signups' do
|
||||
let(:report) { Report.find('signups', cache: true) }
|
||||
|
|
Loading…
Reference in New Issue