FEATURE: 2 new reports: time to first response, topics with no response
FIX: relativeAgeMediumSpan was off by 1 REFACTOR: extracted decimalAdjust & round functions from the poll plugin
This commit is contained in:
+11
-7
@@ -1,9 +1,11 @@
|
||||
Discourse.Report = Discourse.Model.extend({
|
||||
import round from "discourse/lib/round";
|
||||
|
||||
const Report = Discourse.Model.extend({
|
||||
reportUrl: function() {
|
||||
return("/admin/reports/" + this.get('type'));
|
||||
}.property('type'),
|
||||
|
||||
valueAt: function(numDaysAgo) {
|
||||
valueAt(numDaysAgo) {
|
||||
if (this.data) {
|
||||
var wantedDate = moment().subtract(numDaysAgo, 'days').format('YYYY-MM-DD');
|
||||
var item = this.data.find( function(d) { return d.x === wantedDate; } );
|
||||
@@ -14,7 +16,7 @@ Discourse.Report = Discourse.Model.extend({
|
||||
return 0;
|
||||
},
|
||||
|
||||
sumDays: function(startDaysAgo, endDaysAgo) {
|
||||
sumDays(startDaysAgo, endDaysAgo) {
|
||||
if (this.data) {
|
||||
var earliestDate = moment().subtract(endDaysAgo, 'days').startOf('day');
|
||||
var latestDate = moment().subtract(startDaysAgo, 'days').startOf('day');
|
||||
@@ -25,7 +27,7 @@ Discourse.Report = Discourse.Model.extend({
|
||||
sum += datum.y;
|
||||
}
|
||||
});
|
||||
return sum;
|
||||
return round(sum, -2);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -100,7 +102,7 @@ Discourse.Report = Discourse.Model.extend({
|
||||
}
|
||||
}.property('type'),
|
||||
|
||||
percentChangeString: function(val1, val2) {
|
||||
percentChangeString(val1, val2) {
|
||||
var val = ((val1 - val2) / val2) * 100;
|
||||
if( isNaN(val) || !isFinite(val) ) {
|
||||
return null;
|
||||
@@ -111,7 +113,7 @@ Discourse.Report = Discourse.Model.extend({
|
||||
}
|
||||
},
|
||||
|
||||
changeTitle: function(val1, val2, prevPeriodString) {
|
||||
changeTitle(val1, val2, prevPeriodString) {
|
||||
var title = '';
|
||||
var percentChange = this.percentChangeString(val1, val2);
|
||||
if( percentChange ) {
|
||||
@@ -139,7 +141,7 @@ Discourse.Report = Discourse.Model.extend({
|
||||
|
||||
});
|
||||
|
||||
Discourse.Report.reopenClass({
|
||||
Report.reopenClass({
|
||||
find: function(type, startDate, endDate) {
|
||||
|
||||
return Discourse.ajax("/admin/reports/" + type, {data: {
|
||||
@@ -162,3 +164,5 @@ Discourse.Report.reopenClass({
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
export default Report;
|
||||
@@ -58,6 +58,8 @@
|
||||
{{admin-report-counts report=signups}}
|
||||
{{admin-report-counts report=topics}}
|
||||
{{admin-report-counts report=posts}}
|
||||
{{admin-report-counts report=time_to_first_response}}
|
||||
{{admin-report-counts report=topics_with_no_response}}
|
||||
{{admin-report-counts report=likes}}
|
||||
{{admin-report-counts report=flags}}
|
||||
{{admin-report-counts report=bookmarks}}
|
||||
|
||||
Reference in New Issue
Block a user