FIX: improves number/percent support in reports

This commit is contained in:
Joffrey JAFFEUX
2018-08-01 18:40:59 -04:00
committed by GitHub
parent 4a872823e7
commit 9073e11943
13 changed files with 127 additions and 104 deletions

View File

@ -1,6 +1,5 @@
import computed from "ember-addons/ember-computed-decorators";
import { registerTooltip, unregisterTooltip } from "discourse/lib/tooltip";
import { isNumeric } from "discourse/lib/utilities";
const PAGES_LIMIT = 8;
@ -67,14 +66,16 @@ export default Ember.Component.extend({
const computedLabel = label.compute(row);
const value = computedLabel.value;
if (!computedLabel.countable || !value || !isNumeric(value)) {
return undefined;
if (!["seconds", "number", "percent"].includes(label.type)) {
return;
} else {
return sum + value;
return sum + Math.round(value || 0);
}
};
totalsRow[label.mainProperty] = rows.reduce(reducer, 0);
const total = rows.reduce(reducer, 0);
totalsRow[label.mainProperty] =
label.type === "percent" ? Math.round(total / rows.length) : total;
});
return totalsRow;