fix(web): 成片库卡片查重率显示 "-" — mapVideoToProductItem 硬编码 undefined #1608

Merged
xiaoxia merged 1 commits from fix/web-duplicate-rate-mapping into develop 2026-09-01 15:46:12 +08:00
Owner

根因

apps/web/src/api/products/utils.tsmapVideoToProductItem 函数中 duplicate_rate 被硬编码为 undefined

// 后端 /videos 接口暂无 duplicate_rate 字段
duplicate_rate: undefined,

虽然后端 API 已经返回了 duplicate_rate 字段(VideoItemResponse schema 确认),但前端映射函数把它写死了 undefined

前端链路:

  1. mapVideoToProductItemduplicate_rate: undefined
  2. ProductCardduplicateRate = item.duplicate_rate ?? 00
  3. duplicateRate > 0 ? "X%" : "-"0 > 0 = false"-"

所以无论后端返回什么值,前端永远显示 "-"。

修复

  1. types.tsVideoItem 接口增加 duplicate_rate?: number 字段
  2. utils.tsmapVideoToProductItem 改为 duplicate_rate: video.duplicate_rate

影响范围

仅前端代码,不涉及后端/API/DB 变更。

## 根因 `apps/web/src/api/products/utils.ts` 的 `mapVideoToProductItem` 函数中 `duplicate_rate` 被硬编码为 `undefined`: ```typescript // 后端 /videos 接口暂无 duplicate_rate 字段 duplicate_rate: undefined, ``` 虽然后端 API 已经返回了 `duplicate_rate` 字段(`VideoItemResponse` schema 确认),但前端映射函数把它写死了 `undefined`。 前端链路: 1. `mapVideoToProductItem` → `duplicate_rate: undefined` 2. `ProductCard` → `duplicateRate = item.duplicate_rate ?? 0` → `0` 3. `duplicateRate > 0 ? "X%" : "-"` → `0 > 0 = false` → `"-"` 所以无论后端返回什么值,前端永远显示 "-"。 ## 修复 1. **`types.ts`** — `VideoItem` 接口增加 `duplicate_rate?: number` 字段 2. **`utils.ts`** — `mapVideoToProductItem` 改为 `duplicate_rate: video.duplicate_rate` ## 影响范围 仅前端代码,不涉及后端/API/DB 变更。
xiaoxia added 1 commit 2026-09-01 15:14:46 +08:00
fix(web): 成片库卡片查重率显示 '-' — mapVideoToProductItem 硬编码 undefined
AI Code Review / AI Code Review (pull_request) Successful in 3m43s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 2m42s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 5m59s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 4m53s
CI/CD Pipeline / Check push changed paths (pull_request) Has been skipped
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 4s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 5s
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / PR Build API Image (pull_request) Has been skipped
CI/CD Pipeline / PR Build Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / Validate - Style (pull_request) Successful in 3m17s
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Successful in 4m15s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 4m28s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Successful in 4m49s
CI/CD Pipeline / PR Build Web Image (pull_request) Successful in 7m31s
CI/CD Pipeline / Validate - Security (pull_request) Successful in 8m21s
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / CI Gate (pull_request) Successful in 4s
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Canary Release to Production (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
ACR Cleanup / ACR Image Cleanup (pull_request_target) Successful in 2m2s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 3m39s
c11d70d9c9
根因: mapVideoToProductItem 中 duplicate_rate 被硬编码为 undefined,
导致无论后端 API 返回什么值,前端永远显示 '-'。

修复:
- VideoItem 接口增加 duplicate_rate?: number 字段
- mapVideoToProductItem 改为从 video 对象读取 duplicate_rate
Collaborator

【阻塞级判定】

  • 是否存在阻塞级问题:否
  • 阻塞级问题数量:0 个

📊 审查概览

  • 整体评价:通过
  • 建议级问题数量:0 个

🔴 阻塞级问题(必须修复)

💡 改进建议(不阻塞合并)

良好实践

  1. 类型定义安全:在 VideoItem 接口中正确使用了可选类型 duplicate_rate?: number,确保了在旧版本接口数据未包含该字段时,TypeScript 编译不会报错,保证了向后兼容性。
  2. 代码维护及时:移除了不再适用的注释(“后端 /videos 接口暂无 duplicate_rate 字段”),避免了代码与注释不一致的误导。
  3. 逻辑清晰mapVideoToProductItem 函数直接映射了新增字段,逻辑简单直接,符合预期。

🤖 由 AI 代码审查机器人自动生成 | 2026-09-01 07:18:34 | 模型:

### 【阻塞级判定】 - 是否存在阻塞级问题:否 - 阻塞级问题数量:0 个 ### 📊 审查概览 - 整体评价:通过 - 建议级问题数量:0 个 ### 🔴 阻塞级问题(必须修复) 无 ### 💡 改进建议(不阻塞合并) 无 ### ✅ 良好实践 1. **类型定义安全**:在 `VideoItem` 接口中正确使用了可选类型 `duplicate_rate?: number`,确保了在旧版本接口数据未包含该字段时,TypeScript 编译不会报错,保证了向后兼容性。 2. **代码维护及时**:移除了不再适用的注释(“后端 /videos 接口暂无 duplicate_rate 字段”),避免了代码与注释不一致的误导。 3. **逻辑清晰**:`mapVideoToProductItem` 函数直接映射了新增字段,逻辑简单直接,符合预期。 --- <sub>🤖 由 AI 代码审查机器人自动生成 | 2026-09-01 07:18:34 | 模型: </sub> <!-- AI_CODE_REVIEW_AUTO_COMMENT -->

🚀 预览环境已部署

项目 详情
PR号 #1608
预览链接 https://pr-1608.preview.xiaoxiajianji.com
API环境 staging

💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。

🔄 每次提交新代码后预览环境会自动更新。

🗑️ PR 关闭或合并后,预览环境会自动清理。

🚀 **预览环境已部署** | 项目 | 详情 | |------|------| | PR号 | #1608 | | 预览链接 | [https://pr-1608.preview.xiaoxiajianji.com](https://pr-1608.preview.xiaoxiajianji.com) | | API环境 | staging | > 💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。 > > 🔄 每次提交新代码后预览环境会自动更新。 > > 🗑️ PR 关闭或合并后,预览环境会自动清理。
xiaoxia merged commit b48daf346b into develop 2026-09-01 15:46:12 +08:00

🗑️ 预览环境已清理

PR #1608 已关闭或合并,对应的预览环境已被清理。

如有需要,可以重新打开 PR 来重新生成预览环境。

🗑️ **预览环境已清理** PR #1608 已关闭或合并,对应的预览环境已被清理。 > 如有需要,可以重新打开 PR 来重新生成预览环境。
Sign in to join this conversation.