Skip to content

fix: rank detail drawer accounting display - #7959

Merged
fit2cloudwxx merged 1 commit into
v3from
pr@v3@fix_rankDetailDrawerAcDisplay
Nov 17, 2026
Merged

fit2cloudwxx merged 1 commit into
v3from
pr@v3@fix_rankDetailDrawerAcDisplay

Conversation

@shaohuzhang1

@shaohuzhang1 shaohuzhang1 commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

【【系统管理】首页排行榜详情弹窗「对话次数」Tab 下,表头「占比」列位置错误,与原型不符】
https://www.tapd.cn/tapd_fe/45245355/bug/detail/1145245355001078070

</el-table-column>
<el-table-column v-if="activeKind === 'tokens' || activeKind === 'questions'" label="活跃用户" min-width="100">
<template #default="{ row }">{{ numberFormat(row.chat_user_count) }}</template>
</el-table-column>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the diff, here are my observations:

Irregularities / Potential Issues

  1. chat_record_count may be undefined

    • numberFormat(row.chat_record_count) is called without a fallback. Other columns use ?? 0 (e.g., formatTokenNumber(row.total_tokens ?? 0)). If the API can return null/undefined, numberFormat will likely produce NaN, "null", or throw depending on its implementation. Consider row.chat_record_count ?? 0.
  2. Column order change affects UX semantics

    • "对话次数" was moved before "占比". Ensure this matches design specs — reordering columns in a rankings table can shift user expectations, especially since "占比" (el-progress) is typically the visually dominant column placed last.
  3. Possible redundant visibility condition

    • The new "对话次数" column has no v-if, so it always shows, whereas neighboring columns are conditional on activeKind. Verify this is intentional — if the field only makes sense for certain kinds (like questions), you may need a v-if.

Code Style / Formatting

  1. Line length regression
    • The canExport change reverse-wraps a long ternary onto one line (~130 chars). If your project enforces Prettier/ESLint max-len or printWidth: 100/120, this will fail linting. The original multi-line form was more readable. Revert unless a specific style guide requires single-line.

Optimization Suggestions

  1. Memoize/inline guard for numberFormat

    • Wrap fallback into a helper (or update numberFormat itself to accept undefined and default to 0), so all usages are consistent.
  2. computed still fine

    • The canExport behavior is unchanged; no perf concern. Only formatting matters.
  3. Consider :key stability for reordered columns

    • When column order changes across versions, users' persisted table preferences (if any) keyed by label/index could break. If column persistence exists, use explicit prop/column-key attributes (e.g., :prop="activeKind + '_chat_count'" style keys or stable column-key) instead of relying on DOM order.
  4. Test coverage

    • Add/verify unit test asserting "对话次数" renders 0 (not blank/NaN) when chat_record_count is missing.

Summary

  • Must fix: ?? 0 fallback for chat_record_count; revert the long single-line ternary if lint rules apply.
  • Verify: intentional unconditional display of the new column and desired column ordering.
  • Nice-to-have: stable column-key/prop, tests for null-safety.

<span v-else>—</span>
</template>
</el-table-column>
<el-table-column label="均 Tokens/次" min-width="125">

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of the diff

The change simply swaps the order of two <el-table-column> blocks: the "对话次数 / Tokens 消耗" column now comes before the "占比" (ratio) column. Functionally this is a safe, cosmetic reordering. A few observations:

Potential issues / things to verify

  1. No logical dependency broken?

    • The second column's content no longer depends on the first — they are independent. Just confirm there's no CSS/:key or column-index assumption elsewhere (e.g., row-class-name, sortable column indices, table.columns[i] references, or tests that assert column order).
  2. Sorting behavior

    • If either column uses sortable (not shown here), swapping order changes default sort UX. Not visible in the snippet, but worth checking.
  3. Redundant work — repeated activeKind === 'userTokens' checks

    • Both columns compute activeKind === 'userTokens' ? ... : .... Consider extracting a computed property for readability and consistency:
      const secondaryLabel = computed(() =>
        activeKind.value === 'userTokens' ? '对话次数' : 'Tokens 消耗'
      )
      const secondaryField = computed(() =>
        activeKind.value === 'userTokens' ? 'questions' : 'userTokens'
      )
    • Then use :label="secondaryLabel" and formatRankingValue(row, secondaryField).
  4. Defensive checks in the ratio column

    • getRankingRatio(row) may return values outside 0–100 (or NaN). el-progress :percentage expects 0–100; clamp it to avoid rendering warnings:
      Math.min(100, Math.max(0, getRankingRatio(row)))
    • Ensure getRankingRatio doesn't divide by zero when aggregateTotal === 0. You already guard aggregateTotal != null, but 0 passes that check → potential division-by-zero producing Infinity/NaN.
  5. Accessibility / semantics

    • The fallback — is fine, but consider adding a tooltip or aria-label for screen readers explaining why the value is unavailable.
  6. min-width inconsistency

    • New left column uses 125, ratio column 150. Purely visual — acceptable, just confirm intended with the design.

Performance

  • No concerns introduced by this diff; swapping columns has negligible cost. For large tables, mark ratio/progress columns with class-name minimal re-render or consider fixed widths to prevent layout thrash during horizontal scroll.

Summary: The reorder itself is harmless. Main follow-ups: confirm nothing depends on column index/order, clamp el-progress percentages, guard against division by zero, and optionally DRY up the repeated ternary logic via computed properties.

@fit2cloudwxx
fit2cloudwxx merged commit 355def5 into v3 Nov 17, 2026
3 of 4 checks passed
@fit2cloudwxx
fit2cloudwxx deleted the pr@v3@fix_rankDetailDrawerAcDisplay branch November 17, 2026 02:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants