task-117(任务与重复分析中心): 实现重复检查明细列表

新增 duplicate-filter.ts(明细筛选 snake 查询) 与 parseDuplicateItemsPage/
fetchDuplicateItems(GET /duplicate-check-items)。

TDD: task-117.test.ts 8 用例先 RED 后 GREEN。
This commit is contained in:
2026-09-05 17:25:41 +08:00
parent 5ed6824830
commit f9e0381d7d
4 changed files with 189 additions and 1 deletions
@@ -138,3 +138,31 @@ function parseDuplicateMetrics(raw: unknown): DuplicateMetrics | null {
source: text(r.source),
}
}
/** 明细列表分页负载(data: {pending,items,total,page,page_size}) → 前端结果。 */
export function parseDuplicateItemsPage(payload: unknown): {
pending: boolean
scannedAt: string
items: DuplicateItem[]
total: number
page: number
pageSize: number
} {
const core = unwrap<unknown>(payload)
const record = core && typeof core === 'object' ? (core as Record<string, unknown>) : {}
const items = Array.isArray(record.items)
? record.items.map((raw) => parseDuplicateItem(raw)).filter((item): item is DuplicateItem => item !== null)
: []
const total = count(record.total)
const pageNumber = count(record.page) >= 1 ? count(record.page) : 1
const rawSize = record.page_size ?? record.pageSize
const pageSize = count(rawSize) >= 1 ? count(rawSize) : 20
return {
pending: record.pending === true,
scannedAt: text(record.scanned_at ?? record.scannedAt),
items,
total,
page: pageNumber,
pageSize,
}
}