Skip to content
This repository was archived by the owner on Jan 6, 2026. It is now read-only.

Commit b75ae7f

Browse files
authored
fix: Table sorting (#43)
* Fix table sorting * Remove console log * Explicitly convert total column to string * use Number instead of BigInt
1 parent 4c326a9 commit b75ae7f

File tree

1 file changed

+69
-10
lines changed

1 file changed

+69
-10
lines changed

src/index.md

Lines changed: 69 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,10 @@ const tidySparkMinerRates = SparkMinerRates.sort(
5151
return {
5252
...record,
5353
ttfb_ms,
54-
success_rate: `${(record.success_rate * 100).toFixed(2)}%`,
55-
success_rate_http: `${(record.success_rate_http * 100).toFixed(2)}%`,
56-
success_rate_http_head: `${(record.success_rate_http_head * 100).toFixed(2)}%`,
54+
total: Number(record.total),
55+
success_rate: record.success_rate * 100,
56+
success_rate_http: record.success_rate_http * 100,
57+
success_rate_http_head: record.success_rate_http_head * 100,
5758
}
5859
})
5960
const tidySparkClientRates = SparkClientRates.sort(
@@ -63,8 +64,9 @@ const tidySparkClientRates = SparkClientRates.sort(
6364
delete record.successful_http
6465
return {
6566
...record,
66-
success_rate: `${(record.success_rate * 100).toFixed(2)}%`,
67-
success_rate_http: `${(record.success_rate_http * 100).toFixed(2)}%`,
67+
total: Number(record.total),
68+
success_rate: record.success_rate * 100,
69+
success_rate_http: record.success_rate_http * 100,
6870
}
6971
})
7072
const tidySparkAllocatorRates = SparkAllocatorRates.sort(
@@ -74,8 +76,9 @@ const tidySparkAllocatorRates = SparkAllocatorRates.sort(
7476
delete record.successful_http
7577
return {
7678
...record,
77-
success_rate: `${(record.success_rate * 100).toFixed(2)}%`,
78-
success_rate_http: `${(record.success_rate_http * 100).toFixed(2)}%`,
79+
total: Number(record.total),
80+
success_rate: record.success_rate * 100,
81+
success_rate_http: record.success_rate_http * 100,
7982
}
8083
})
8184
```
@@ -436,8 +439,29 @@ const searchMinerStats = view(
436439
)
437440
```
438441
442+
```js
443+
const minerStatsTable = Inputs.table(searchMinerStats, {
444+
rows: 16,
445+
format: {
446+
total: (v) => v?.toString(),
447+
miner_id: (v) => htl.html`<a href=./provider/${v} target=_blank>${v}</a>`,
448+
ttfb_ms: (v) => v?.toFixed(0),
449+
success_rate: (v) => `${v?.toFixed(2)}%`,
450+
success_rate_http: (v) => `${v?.toFixed(2)}%`,
451+
success_rate_http_head: (v) => `${v?.toFixed(2)}%`,
452+
},
453+
sort: {
454+
ttfb_ms: 'asc',
455+
success_rate: 'desc',
456+
success_rate_http: 'desc',
457+
success_rate_http_head: 'desc',
458+
total: 'desc',
459+
},
460+
})
461+
```
462+
439463
<div class="card" style="padding: 0;">
440-
${Inputs.table(searchMinerStats, {rows: 16, format: {miner_id: id => htl.html`<a href=./provider/${id} target=_blank>${id}</a>`}})}
464+
${minerStatsTable}
441465
</div>
442466
443467
<div class="divider"></div>
@@ -453,8 +477,25 @@ const searchClientStats = view(
453477
)
454478
```
455479
480+
```js
481+
const clientStatsTable = Inputs.table(searchClientStats, {
482+
rows: 16,
483+
format: {
484+
total: (v) => v?.toString(),
485+
client_id: (v) => htl.html`<a href=./client/${v} target=_blank>${v}</a>`,
486+
success_rate: (v) => `${v?.toFixed(2)}%`,
487+
success_rate_http: (v) => `${v?.toFixed(2)}%`,
488+
},
489+
sort: {
490+
success_rate: 'desc',
491+
success_rate_http: 'desc',
492+
total: 'desc',
493+
},
494+
})
495+
```
496+
456497
<div class="card" style="padding: 0;">
457-
${Inputs.table(searchClientStats, {rows: 16, format: {client_id: id => htl.html`<a href=./client/${id} target=_blank>${id}</a>`}})}
498+
${clientStatsTable}
458499
</div>
459500
460501
<div class="divider"></div>
@@ -470,8 +511,26 @@ const searchAllocatorStats = view(
470511
)
471512
```
472513
514+
```js
515+
const allocatorStatsTable = Inputs.table(searchAllocatorStats, {
516+
rows: 16,
517+
format: {
518+
total: (v) => v?.toString(),
519+
allocator_id: (v) =>
520+
htl.html`<a href=./allocator/${v} target=_blank>${v}</a>`,
521+
success_rate: (v) => `${v?.toFixed(2)}%`,
522+
success_rate_http: (v) => `${v?.toFixed(2)}%`,
523+
},
524+
sort: {
525+
success_rate: 'desc',
526+
success_rate_http: 'desc',
527+
total: 'desc',
528+
},
529+
})
530+
```
531+
473532
<div class="card" style="padding: 0;">
474-
${Inputs.table(searchAllocatorStats, {rows: 16, format: {allocator_id: id => htl.html`<a href=./allocator/${id} target=_blank>${id}</a>`}})}
533+
${allocatorStatsTable}
475534
</div>
476535
477536
<style>

0 commit comments

Comments
 (0)