mirror of
https://github.com/discourse/discourse.git
synced 2025-05-28 01:56:58 +08:00
Admin controls to select a date range for reports
This commit is contained in:
@ -140,9 +140,12 @@ Discourse.Report = Discourse.Model.extend({
|
||||
});
|
||||
|
||||
Discourse.Report.reopenClass({
|
||||
find: function(type) {
|
||||
var model = Discourse.Report.create({type: type});
|
||||
Discourse.ajax("/admin/reports/" + type).then(function (json) {
|
||||
find: function(type, startDate, endDate) {
|
||||
|
||||
return Discourse.ajax("/admin/reports/" + type, {data: {
|
||||
start_date: startDate,
|
||||
end_date: endDate
|
||||
}}).then(function (json) {
|
||||
// Add a percent field to each tuple
|
||||
var maxY = 0;
|
||||
json.report.data.forEach(function (row) {
|
||||
@ -153,9 +156,9 @@ Discourse.Report.reopenClass({
|
||||
row.percentage = Math.round((row.y / maxY) * 100);
|
||||
});
|
||||
}
|
||||
var model = Discourse.Report.create({type: type});
|
||||
model.setProperties(json.report);
|
||||
model.set('loaded', true);
|
||||
return model;
|
||||
});
|
||||
return(model);
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user