数据目录闭环(前端)复核修正(审阅队列):每一项的位置按 path 说到列(「列 ticket_no 的度量类型」「表的有效记录条件」「指向 members 的关联关系」,同提案卡片),复选框的读屏名也写到列——服务端的 field_label 只是字段的叫法(「码值」「中文名」),列名另放在 column,列级的项只写它分不清是哪一列;审阅进度三行同一个口径:已确认 ÷(已确认 + 待确认),已驳回的、有确证的不计入,审完了就是 100%,悬停写明口径;常用表写实际几张(服务端只算被运行用过的),没有时写「还没有运行用过的表」,不再写死「常用 20 张表」;「用过这张表的运行」写「共 N 次运行」并说明和表头按查询算的使用次数不是一个数,队列里使用次数的悬停同表清单;check-catalog-loop 的队列、进度、导入预览夹具照服务端的真实形状(field_label 只写字段名、带 column,reasons 用服务端的说法,进度带 items_proposed,导入报告带 version、error、冲突的状态),补位置、进度口径的纯函数和页面检查

This commit is contained in:
ThearchyHelios
2026-10-14 10:10:07 +08:00
parent dff53db165
commit 299224acaf
6 changed files with 204 additions and 61 deletions
+24 -8
View File
@@ -3082,7 +3082,11 @@ export const CATALOG_ASSISTANT_TEXT = {
// - 「影响数字的项」:有效记录条件、去重规则、业务日期、关联关系、业务主键、度量类型——写错了查出来的数就不对,排在最前;
// 「名称和含义」:中文名、含义、单位、码值、粒度、表类型。
// - 审阅过的项原地标出结果(已确认、已驳回、未生效),刷新队列后才移除;「撤销审阅」回到起草时的状态(推断)。
// - 「常用 20 张表」:使用次数最多的 20 张。进度写「已确认 42%」。
// - 每一项的位置写「列 status 的码值」「表的有效记录条件」「指向 parks 的关联关系」(同提案卡片),不只写字段名。
// - 「常用 N 张表」:被运行用过、使用次数最多的前几张(最多 20 张),N 写实际张数;没有运行用过的表时写明。
// - 进度写「已确认 42%」,三行同一个口径:已确认 ÷(已确认 + 待确认);已驳回的、有确证的(外键约束)不计入。
// - 「使用 N 次」是所在表被运行查询过的次数(按查询算,同表清单);「用过这张表的运行」写「共 N 次运行」(按运行算),
// 两个数不一样,各自写明单位。
// ===========================================================================
export const CATALOG_REVIEW_TEXT = {
@@ -3120,7 +3124,7 @@ export const CATALOG_REVIEW_TEXT = {
selected: (n: number) => `已选 ${formatNumber(n)} 项`,
clearSelection: '取消选择',
usage: (n: number) => `使用 ${formatNumber(n)} 次`,
usageHint: '所在表被运行查询过的次数',
usageHint: '所在表被运行查询过的次数,同一次运行中结果相同的重复查询只算一次',
open: (where: string, table: string) => `打开「${table}」,查看${where}`,
reasonsLabel: '排在这里的原因',
// ---- 成批审阅
@@ -3151,15 +3155,25 @@ export const CATALOG_REVIEW_TEXT = {
failedAll: (reason: string) => `未能提交:${reason}`,
// ---- 进度
progressTitle: '审阅进度',
/** 常用表:被运行用过、使用次数最多的前几张(最多 topN 张),n 是实际张数 */
progressTop: (n: number) => `常用 ${formatNumber(n)} 张表`,
progressTopHint: (n: number) => `使用次数最多的 ${formatNumber(n)} 张表里的项`,
progressTopHint: (n: number, topN: number) => (n > 0
? `被运行用过、使用次数最多的 ${formatNumber(n)} 张表里的项(最多取 ${formatNumber(topN)} 张)`
: `被运行用过、使用次数最多的表里的项(最多取 ${formatNumber(topN)} 张)`),
progressTopNone: '常用表',
progressTopEmpty: '还没有运行用过的表',
progressAll: '全部表',
progressAllHint: '这个数据源全部表里的项',
progressFacts: '影响数字的项',
progressFactsHint: '有效记录条件、去重规则、业务日期、关联关系、业务主键、度量类型',
confirmedPct: (pct: number | null) => (pct == null ? '还没有目录项' : `已确认 ${formatNumber(pct)}%`),
itemsOf: (confirmed: number, total: number) => `${formatNumber(confirmed)} / ${formatNumber(total)} 项`,
allDetail: (proposed: number, rejected: number) => `推断 ${formatNumber(proposed)} 项、已驳回 ${formatNumber(rejected)} 项`,
factsDetail: (proposed: number, confirmed: number) => `待确认 ${formatNumber(proposed)} 项、已确认 ${formatNumber(confirmed)} 项`,
progressRule: '已确认 ÷(已确认 + 待确认):已驳回的、有确证的(外键约束)不用再确认,不计入',
/** 一行进度:已确认百分比和待确认几项;不知道待确认几项时只写已确认几项 */
progressText: (pct: number | null, confirmed: number, proposed: number | null, total: number | null) => {
if (total === 0) return '还没有目录项'
if (proposed == null) return `已确认 ${formatNumber(confirmed)} 项`
if (pct == null) return '没有待确认的项'
return `已确认 ${formatNumber(pct)}% · 待确认 ${formatNumber(proposed)} 项`
},
progressFailed: '无法读取审阅进度',
// ---- 没选中项时的右栏
overviewTitle: '从左侧队列挑一项开始审阅',
@@ -3178,8 +3192,10 @@ export const CATALOG_USAGE_TEXT = {
show: '查看用过这张表的运行',
hide: '收起',
none: '还没有运行查询过这张表',
/** 按运行算(一次运行查询了几次这张表都只算一次),和表头按查询算的「使用 N 次」不是一个数 */
count: (shown: number, total: number) => (total > shown
? `最近 ${formatNumber(shown)} 次,共 ${formatNumber(total)} 次` : `共 ${formatNumber(total)} 次`),
? `共 ${formatNumber(total)} 次运行,显示最近 ${formatNumber(shown)} 次` : `共 ${formatNumber(total)} 次运行`),
countHint: '按运行算:一次运行查询了几次这张表都只算一次;表头的使用次数按查询算,两个数可能不一样',
error: '无法读取用过这张表的运行',
retry: '重试',
unnamed: '未保存的工作流',
+50 -23
View File
@@ -10,15 +10,17 @@ import { errorMessage } from '../../lib/errors'
import { CATALOG_REVIEW_TEXT as RT } from '../../lib/terms'
import { StatusChip } from './parts'
import {
REVIEW_BATCH_MAX, REVIEW_KINDS, REVIEW_PAGE, applyResults, batchTargets, itemKey, percentOf, statusOf, syncFromDetail,
REVIEW_BATCH_MAX, REVIEW_KINDS, REVIEW_PAGE, applyResults, batchTargets, confirmProgress, itemKey, reviewWhere, statusOf,
syncFromDetail,
} from './review'
import type { ItemOutcome } from './review'
// ===========================================================================
// 审阅队列(数据目录页的「审阅队列」视图,左栏):跨表列出推断项,顺序由服务端排好(所在表的使用次数 × 这一项对数字的
// 影响 × 来源),每一项写为什么排在这里。可以按项(影响数字的项 / 名称和含义)和表筛选;多选后成批确认、驳回,审阅过的
// 原地标出结果(冲突的标出来),选中可以撤销审阅;刷新队列后审阅过的才移除。顶上是审阅进度:常用 20 张表、全部表、
// 影响数字的项各确认了多少。点开一项,右栏是所在表的详情(滚到那一项、标出来)和用过这张表的运行。
// 原地标出结果(冲突的标出来),选中可以撤销审阅;刷新队列后审阅过的才移除。顶上是审阅进度:常用表(使用次数最多、
// 被运行用过的前 20 张)、全部表、影响数字的项各确认了多少,三行同一个口径。点开一项,右栏是所在表的详情(滚到那一项、
// 标出来)和用过这张表的运行。
// ===========================================================================
export function ReviewQueue({ sourceId, rows, kind, table, activeKey, detailSync, onParams, onOpenItem, onChanged }: {
@@ -313,7 +315,8 @@ const QueueRow = memo(function QueueRow({ item: i, itemKeyText, tableLabel, outc
onOpen: (item: CatalogReviewItem) => void
}) {
const status = statusOf(i, outcome)
const where = i.field_label || i.path
// 位置按 path 说(「列 status 的码值」):服务端的 field_label 只是字段的叫法,列级的项只写它分不清是哪一列
const where = reviewWhere(i)
const tableText = tableLabel ? `${tableLabel}(${i.table_name})` : i.table_name
const mono = i.field === 'valid_filter' || i.field === 'keys'
return (
@@ -327,7 +330,7 @@ const QueueRow = memo(function QueueRow({ item: i, itemKeyText, tableLabel, outc
<button type="button" className="min-w-0 flex-1 px-2 py-2 text-left outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--accent)]"
onClick={() => onOpen(i)} aria-current={active ? 'true' : undefined} title={RT.open(where, i.table_name)} data-review-open="">
<span className="flex items-baseline gap-2">
<span className="min-w-0 flex-1 truncate text-xs font-medium text-fg">{where}</span>
<span className="min-w-0 flex-1 truncate text-xs font-medium text-fg" data-review-where="">{where}</span>
<span className="tnum shrink-0 text-2xs text-faint" title={RT.usageHint}>{RT.usage(i.table_usage)}</span>
</span>
<span className="mt-0.5 block truncate text-2xs text-faint" title={tableText}>{tableText}</span>
@@ -354,7 +357,11 @@ const QueueRow = memo(function QueueRow({ item: i, itemKeyText, tableLabel, outc
)
})
/** 审阅进度:常用 20 张表、全部表、影响数字的项。数字写在字里,色条只给眼睛看 */
/**
* 审阅进度:常用表、全部表、影响数字的项,三行同一个口径——已确认 ÷(已确认 + 待确认),已驳回的、有确证的不计入,
* 审完了就是 100%。常用表只算被运行用过的(最多 top_n 张),标签写实际几张,一张都没有时写明还没有运行用过的表。
* 数字写在字里,色条只给眼睛看
*/
function ProgressBlock({ progress, failed }: { progress: CatalogReviewProgress | null; failed: boolean }) {
if (!progress) {
return (
@@ -364,33 +371,53 @@ function ProgressBlock({ progress, failed }: { progress: CatalogReviewProgress |
)
}
const { top, all, facts } = progress
const topPct = percentOf(top.items_confirmed, top.items_total)
const allPct = percentOf(all.items_confirmed, all.items_total)
const factsPct = percentOf(facts.confirmed, facts.proposed + facts.confirmed)
const topTables = Math.max(0, top.tables ?? 0)
const topLine = confirmProgress(top.items_confirmed, top.items_proposed)
const allLine = confirmProgress(all.items_confirmed, all.items_proposed)
const factsLine = confirmProgress(facts.confirmed, facts.proposed)
return (
<section className="space-y-1.5 border-b px-3 py-2.5" aria-label={RT.progressTitle} data-review-progress="">
<ProgressLine label={RT.progressTop(progress.top_n)} hint={RT.progressTopHint(progress.top_n)} pct={topPct}
text={`${RT.confirmedPct(topPct)} · ${RT.itemsOf(top.items_confirmed, top.items_total)}`} attr="top" />
<ProgressLine label={RT.progressAll} pct={allPct}
text={`${RT.confirmedPct(allPct)} · ${RT.allDetail(all.items_proposed, all.items_rejected)}`} attr="all" />
<ProgressLine label={RT.progressFacts} hint={RT.progressFactsHint} pct={factsPct}
text={RT.factsDetail(facts.proposed, facts.confirmed)} attr="facts" warn={facts.proposed > 0} />
{topTables > 0
? (
<ProgressLine label={RT.progressTop(topTables)} hint={RT.progressTopHint(topTables, progress.top_n)} line={topLine}
total={top.items_total} attr="top" />
)
: (
<div className="flex items-baseline gap-2 text-2xs" data-review-progress-line="top" data-review-progress-top="" data-review-progress-none="">
<span className="shrink-0 font-medium text-dim" title={RT.progressTopHint(0, progress.top_n)}>{RT.progressTopNone}</span>
<span className="min-w-0 flex-1 truncate text-right text-faint">{RT.progressTopEmpty}</span>
</div>
)}
<ProgressLine label={RT.progressAll} hint={RT.progressAllHint} line={allLine} total={all.items_total} attr="all" />
<ProgressLine label={RT.progressFacts} hint={RT.progressFactsHint} line={factsLine} total={null} attr="facts"
warn={facts.proposed > 0} />
</section>
)
}
function ProgressLine({ label, hint, pct, text, attr, warn = false }: {
label: string; hint?: string; pct: number | null; text: string; attr: string; warn?: boolean
function ProgressLine({ label, hint, line, total, attr, warn = false }: {
label: string
hint: string
line: ReturnType<typeof confirmProgress>
/** 这一行一共几项(全部状态):0 时写还没有目录项;不知道时为 null */
total: number | null
attr: string
warn?: boolean
}) {
const text = RT.progressText(line.pct, line.confirmed, line.proposed, total)
return (
<div className="text-2xs" data-review-progress-line={attr} {...{ [`data-review-progress-${attr}`]: '' }}>
<div className="text-2xs" data-review-progress-line={attr} {...{ [`data-review-progress-${attr}`]: '' }}
data-review-progress-pct={line.pct ?? ''}>
<div className="flex items-baseline gap-2">
<span className="shrink-0 font-medium text-dim" title={hint}>{label}</span>
<span className={clsx('tnum min-w-0 flex-1 truncate text-right', warn ? 'text-[var(--st-waiting)]' : 'text-faint')} title={text}>{text}</span>
</div>
<div className="mt-0.5 h-1 overflow-hidden rounded-full bg-hover" aria-hidden>
<div className="h-full rounded-full bg-[var(--st-done)]" style={{ width: `${pct ?? 0}%` }} />
<span className="shrink-0 font-medium text-dim" title={`${hint}\n${RT.progressRule}`}>{label}</span>
<span className={clsx('tnum min-w-0 flex-1 truncate text-right', warn ? 'text-[var(--st-waiting)]' : 'text-faint')}
title={`${text}\n${RT.progressRule}`}>{text}</span>
</div>
{line.pct != null && (
<div className="mt-0.5 h-1 overflow-hidden rounded-full bg-hover" aria-hidden>
<div className="h-full rounded-full bg-[var(--st-done)]" style={{ width: `${line.pct}%` }} />
</div>
)}
</div>
)
}
+1 -1
View File
@@ -66,7 +66,7 @@ export function TableUsageList({ sourceId, table, usage, autoLoad = false }: {
if (!data.runs.length) return <p className="rounded-lg border px-3 py-4 text-xs text-faint" data-table-usage="0">{T.none}</p>
return (
<div data-table-usage={data.total}>
<p className="mb-1 text-2xs text-faint">{T.count(data.runs.length, data.total)}</p>
<p className="mb-1 text-2xs text-faint" title={T.countHint} data-table-usage-count="">{T.count(data.runs.length, data.total)}</p>
<ul className="divide-y divide-[var(--hairline)] rounded-lg border bg-panel">
{data.runs.map((r) => {
const name = r.workflow_name?.trim() || T.unnamed
+27
View File
@@ -1,6 +1,8 @@
import type {
CatalogNotes, CatalogReviewAction, CatalogReviewBatchResult, CatalogReviewItem, CatalogReviewKind, CatalogStatus,
} from '../../types'
import { CATALOG_TEXT } from '../../lib/terms'
import { patchTarget, patchWhere } from '../../run/catalogPatch'
import { slotsOf } from './model'
// ===========================================================================
@@ -48,6 +50,18 @@ export function writeReviewParams(p: URLSearchParams, s: Partial<ReviewParams>):
/** 队列一项的键(表名里、路径里都可能有句点,中间用一个不会出现的字符隔开) */
export const itemKey = (i: { table_name: string; path: string }) => `${i.table_name}\u0000${i.path}`
/**
* 队列里一项的位置,说法同提案卡片:「列 status 的码值」「表的有效记录条件」「指向 parks 的关联关系」。服务端的
* field_label 只是字段的叫法(「码值」),列级的项占了队列的大半,只写它分不清是哪一列,所以按 path 说;认不出的
* 路径再用 column 加 field_label
*/
export function reviewWhere(i: Pick<CatalogReviewItem, 'path' | 'value' | 'field_label'> & { column?: string | null }): string {
if (patchTarget(i.path)) return patchWhere({ path: i.path, before: i.value ?? null, after: i.value ?? null })
const label = i.field_label?.trim()
if (i.column && label) return CATALOG_TEXT.whereColumn(i.column, label)
return label || i.path
}
/** 一项审阅过之后的处境:成功(现在的状态、这张表写入后的版本)、冲突(这张表刚被改过)、没成功(服务端的原因) */
export type ItemOutcome =
| { kind: 'ok'; action: CatalogReviewAction; status: CatalogStatus }
@@ -130,3 +144,16 @@ export function syncFromDetail(items: CatalogReviewItem[], table: string, notes:
/** 百分比(四舍五入到整数);分母为 0 时为 null */
export const percentOf = (n: number, total: number): number | null => (total > 0 ? Math.round((n / total) * 100) : null)
/**
* 审阅进度的一行(常用表、全部表、影响数字的项同一个口径):已确认 ÷(已确认 + 待确认)。已驳回的、有确证的(外键约束)
* 不用再确认,不计入,审完了就是 100%。不知道待确认几项(服务端没给)时 pct 为 null,只写已确认几项
*/
export function confirmProgress(confirmed: number, proposed: number | null | undefined): {
pct: number | null; confirmed: number; proposed: number | null
} {
const c = Math.max(0, confirmed || 0)
if (typeof proposed !== 'number' || !Number.isFinite(proposed)) return { pct: null, confirmed: c, proposed: null }
const p = Math.max(0, proposed)
return { pct: percentOf(c, c + p), confirmed: c, proposed: p }
}
+15 -5
View File
@@ -3077,10 +3077,15 @@ export interface CatalogReviewItem {
table_name: string
/** 审阅接口的路径写法 */
path: string
/** 字段名(valid_filter、label……) */
/** 字段名(valid_filter、label……;关联关系是 relation) */
field: string
/** 给人看的位置(服务端写好的,比如「列 status 的码值」) */
/**
* 字段的界面叫法(服务端写好的「中文名」「码值」「有效记录条件」「关联关系」),不含是哪一列:界面上的位置按 path
* 说(「列 status 的码值」,review.ts 的 reviewWhere)
*/
field_label: string
/** 列级的项是哪一列;表级的项、关联关系为 null。接口约定里没有写明,服务端给了才用 */
column?: string | null
value: unknown
/** 值写成一行字(服务端写好的) */
display: string
@@ -3137,11 +3142,16 @@ export interface CatalogTableUsage {
runs: CatalogUsageRun[]
}
/** GET /catalog/review-progress:常用的前 top_n 张表、全部表、影响数字的项各审阅到哪儿 */
/**
* GET /catalog/review-progress:常用的前 top_n 张表、全部表、影响数字的项各审阅到哪儿。
* 「常用表」只算被运行用过的:tables 可能比 top_n 少,没有运行时是 0。三行的进度都按「已确认 ÷(已确认 + 待确认)」算
* (review.ts 的 confirmProgress):已驳回的、有确证的(外键约束)不用再确认,不计入
*/
export interface CatalogReviewProgress {
top_n: number
top: { tables: number; items_total: number; items_confirmed: number }
all: { items_total: number; items_confirmed: number; items_proposed: number; items_rejected: number }
/** items_proposed、items_verified:接口约定里没有写明,服务端给了才用(没有待确认数时只写已确认几项) */
top: { tables: number; items_total: number; items_confirmed: number; items_proposed?: number; items_verified?: number }
all: { items_total: number; items_confirmed: number; items_proposed: number; items_rejected: number; items_verified?: number }
facts: { proposed: number; confirmed: number }
}