mirror of
https://github.com/discourse/discourse.git
synced 2025-05-28 13:51:18 +08:00
FIX: Cast all numerical values in reports (#8087)
* FIX: Cast all numerical values in reports The backend can return some numerical values in report as strings. That results in unexpected order of values when sorting report tables. * Create `toNumber()` helper The `typeof` and `parseFloat` seem to be the fastest path: https://jsperf.com/number-vs-typeof-vs-parsefloat#results
This commit is contained in:
@ -7,7 +7,7 @@ let signups = {
|
||||
yaxis: "Number of signups",
|
||||
description: "New account registrations for this period",
|
||||
data: [
|
||||
{ x: "2018-06-16", y: 12 },
|
||||
{ x: "2018-06-16", y: "12" },
|
||||
{ x: "2018-06-17", y: 16 },
|
||||
{ x: "2018-06-18", y: 42 },
|
||||
{ x: "2018-06-19", y: 38 },
|
||||
@ -18,7 +18,7 @@ let signups = {
|
||||
{ x: "2018-06-24", y: 17 },
|
||||
{ x: "2018-06-25", y: 27 },
|
||||
{ x: "2018-06-26", y: 32 },
|
||||
{ x: "2018-06-27", y: 7 }
|
||||
{ x: "2018-06-27", y: "7" }
|
||||
],
|
||||
start_date: "2018-06-16T00:00:00Z",
|
||||
end_date: "2018-07-16T23:59:59Z",
|
||||
|
@ -398,7 +398,7 @@ QUnit.test("computed labels", assert => {
|
||||
username: "joffrey",
|
||||
user_id: 1,
|
||||
user_avatar: "/",
|
||||
flag_count: 1876,
|
||||
flag_count: "1876",
|
||||
time_read: 287362,
|
||||
note: "This is a long note",
|
||||
topic_id: 2,
|
||||
@ -470,7 +470,7 @@ QUnit.test("computed labels", assert => {
|
||||
assert.equal(flagCountLabel.type, "number");
|
||||
let computedFlagCountLabel = flagCountLabel.compute(row);
|
||||
assert.equal(computedFlagCountLabel.formatedValue, "1.9k");
|
||||
assert.equal(computedFlagCountLabel.value, 1876);
|
||||
assert.strictEqual(computedFlagCountLabel.value, 1876);
|
||||
computedFlagCountLabel = flagCountLabel.compute(row, {
|
||||
formatNumbers: false
|
||||
});
|
||||
|
Reference in New Issue
Block a user