mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 13:51:09 +08:00
FIX: improves number/percent support in reports
This commit is contained in:
@ -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;
|
||||
|
Reference in New Issue
Block a user