mirror of
https://github.com/discourse/discourse.git
synced 2026-08-04 10:23:17 -05:00
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;
|
||||
Reference in New Issue
Block a user