fix(analysis): 排行分页后名次从 1 重新开始,应为 11/21…
现象:翻到第 2 页,名次列仍是 1~10。
根因:TopAppsTable 用页内下标算名次(index + 1),分页后每页都从 1 开始。
修复:新增 startIndex 参数,由调用方传入当前页在整体排行中的偏移;
分析页传 (page - 1) * 10,于是第 2 页为 11~20、第 3 页 21~30。
实测:tsc 通过;Pod = Hub latest = 9026d0e4c582
This commit is contained in:
1 parent
fdd705c4b4
commit
f1fc7b4a9a
2 files changed
+6
-2
No files matched your search
@@ -19,12 +19,15 @@ function Sparkline({ values }: { values: number[] }) {
|
|||||||
|
|
||||||
/** 应用日志量排行表:哪个 deployment 日志量最大、错误最多一目了然 */
|
/** 应用日志量排行表:哪个 deployment 日志量最大、错误最多一目了然 */
|
||||||
export const TopAppsTable = memo(function TopAppsTable({
|
export const TopAppsTable = memo(function TopAppsTable({
|
||||||
apps, total, appLabel, onViewLogs,
|
apps, total, appLabel, onViewLogs, startIndex = 0,
|
||||||
}: {
|
}: {
|
||||||
apps: AppRow[]
|
apps: AppRow[]
|
||||||
total: number
|
total: number
|
||||||
appLabel: string
|
appLabel: string
|
||||||
onViewLogs: (query: string) => void
|
onViewLogs: (query: string) => void
|
||||||
|
/* 当前页第一条在整体排行中的偏移(分页后名次要接着往下数:
|
||||||
|
第 2 页应该从 11 开始,而不是重新从 1 开始) */
|
||||||
|
startIndex?: number
|
||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation('analysis')
|
const { t } = useTranslation('analysis')
|
||||||
if (apps.length === 0) {
|
if (apps.length === 0) {
|
||||||
@@ -59,7 +62,7 @@ export const TopAppsTable = memo(function TopAppsTable({
|
|||||||
const selector = `{namespace="${row.namespace}", ${appLabel}="${row.app}"}`
|
const selector = `{namespace="${row.namespace}", ${appLabel}="${row.app}"}`
|
||||||
const metric = metricOf(row)
|
const metric = metricOf(row)
|
||||||
return <tr key={`${row.app}-${row.namespace}`} className="hover:bg-muted/40">
|
return <tr key={`${row.app}-${row.namespace}`} className="hover:bg-muted/40">
|
||||||
<td className="px-3 py-2 tabular-nums text-muted-foreground">{index + 1}</td>
|
<td className="px-3 py-2 tabular-nums text-muted-foreground">{startIndex + index + 1}</td>
|
||||||
<td className="max-w-56 truncate px-3 py-2 font-medium" title={row.app || undefined}>{row.app || t('table.untagged')}</td>
|
<td className="max-w-56 truncate px-3 py-2 font-medium" title={row.app || undefined}>{row.app || t('table.untagged')}</td>
|
||||||
<td className="max-w-40 truncate px-3 py-2 text-muted-foreground" title={row.namespaces.join(', ')}>{row.namespace || '—'}</td>
|
<td className="max-w-40 truncate px-3 py-2 text-muted-foreground" title={row.namespaces.join(', ')}>{row.namespace || '—'}</td>
|
||||||
{useBytes
|
{useBytes
|
||||||
|
|||||||
@@ -385,6 +385,7 @@ const AnalysisPage = memo(function AnalysisPage() {
|
|||||||
) : (
|
) : (
|
||||||
<TopAppsTable
|
<TopAppsTable
|
||||||
apps={rankPageRows}
|
apps={rankPageRows}
|
||||||
|
startIndex={(rankSafePage - 1) * RANK_PAGE_SIZE}
|
||||||
/* 分母必须是同一口径的合计:按体积排行时用体积合计,
|
/* 分母必须是同一口径的合计:按体积排行时用体积合计,
|
||||||
按条数排行时用条数合计,混用会让占比全部算成 0.0x% */
|
按条数排行时用条数合计,混用会让占比全部算成 0.0x% */
|
||||||
total={rankTotal}
|
total={rankTotal}
|
||||||
|
|||||||
Reference in new issue
Block a user