mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 00:41:16 +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:
@ -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