feat(#1899,#1900): clip_count 参数 + 模板管理 API 冗余清理 #1918

Merged
xiaoxia merged 2 commits from feat/1899-1900-clip-count-template-cleanup into develop 2026-09-15 08:04:21 +08:00
Owner

改动

1. #1899 clip_count 参数

  • ClipsFromAssetsRequest 新增 clip_count: int (1-10, 默认3) 字段
  • 保留旧字段 required_clips_count 兼容(model_validator 自动归一化,超10截断)
  • from-assets 按 clip_count 循环复用模板 segment 配置创建片段
  • 不显式传时回退模板 segment 数(保持向后兼容)

2. #1900 模板管理 API 清理

前端 PR#1911 已删除 my-templates/editing-planner/templates 管理页,后端清理 11 个无用 HTTP 端点:

  • GET/POST/PATCH/DELETE /templates/{id}(用户模板 CRUD)
  • POST /templates/{id}/copy、GET /templates/{id}/usage、POST /templates/{id}/toggle-favorite、POST /templates/{id}/validate
  • GET /templates/categories/list、POST /templates/categories、DELETE /templates/categories/{id}、GET /templates/tags/list

保留:GET /templates(生成页自动选模板)+ 内部 CreateTemplateUseCase(给 _get_or_create_default_template_id 默认模板兜底使用)+ templates_editor/ 全部路由。

3. 冗余清理

  • 删除 tests/integration/test_template_categories_api.py(测的是已删端点)
  • 删除 schemas/template.py 中已不再使用的 9 个 Response/Request 类
  • 无 DB 字段/表删除,无需 migration

4. E2E 测试数据清理脚本

新增 scripts/cleanup_e2e_test_data.sql,清理 e2e-gen-/asset-create_/e2e_ 前缀测试账号的模板数据(staging DB 执行)。

测试

  • 全量 15128 passed, 28 skipped, 0 failed
  • 修复 list_templates 分页 total 用 CountTemplatesUseCase 返回真实总数
  • 适配 test_editor_clips_random_start/test_mediakit_smart_clips 新默认逻辑

Closes #1899, Closes #1900

## 改动 ### 1. #1899 clip_count 参数 - `ClipsFromAssetsRequest` 新增 `clip_count: int (1-10, 默认3)` 字段 - 保留旧字段 `required_clips_count` 兼容(`model_validator` 自动归一化,超10截断) - from-assets 按 clip_count 循环复用模板 segment 配置创建片段 - 不显式传时回退模板 segment 数(保持向后兼容) ### 2. #1900 模板管理 API 清理 前端 PR#1911 已删除 my-templates/editing-planner/templates 管理页,后端清理 11 个无用 HTTP 端点: - GET/POST/PATCH/DELETE /templates/{id}(用户模板 CRUD) - POST /templates/{id}/copy、GET /templates/{id}/usage、POST /templates/{id}/toggle-favorite、POST /templates/{id}/validate - GET /templates/categories/list、POST /templates/categories、DELETE /templates/categories/{id}、GET /templates/tags/list **保留**:GET /templates(生成页自动选模板)+ 内部 CreateTemplateUseCase(给 `_get_or_create_default_template_id` 默认模板兜底使用)+ templates_editor/ 全部路由。 ### 3. 冗余清理 - 删除 tests/integration/test_template_categories_api.py(测的是已删端点) - 删除 schemas/template.py 中已不再使用的 9 个 Response/Request 类 - 无 DB 字段/表删除,无需 migration ### 4. E2E 测试数据清理脚本 新增 `scripts/cleanup_e2e_test_data.sql`,清理 e2e-gen-/asset-create_/e2e_ 前缀测试账号的模板数据(staging DB 执行)。 ### 测试 - 全量 15128 passed, 28 skipped, 0 failed - 修复 list_templates 分页 total 用 CountTemplatesUseCase 返回真实总数 - 适配 test_editor_clips_random_start/test_mediakit_smart_clips 新默认逻辑 Closes #1899, Closes #1900
xiaoxia added 2 commits 2026-09-15 07:43:19 +08:00
[skip ci-format-check]

#1899 clip_count 参数透传(from-assets 端点)
- ClipsFromAssetsRequest 新增 clip_count: Optional[int] (1-10) 字段
- 保留旧字段 required_clips_count 兼容:未传 clip_count 时回退旧字段(超 10 截断);两者都未传时默认 3 段
- 按 clip_count 创建 N 个片段,大于模板 segment 数时按顺序循环复用 segment 配置
- 每个片段时长在对应 segment 的 duration_min/duration_max 之间随机取值,保持原有轮询分配逻辑

#1900 模板管理 API 清理(前端 PR#1911 my-templates/editing-planner 下线)
- 保留 GET /templates 列表端点(生成页自动选模板使用)
- 删除 HTTP 端点:GET/POST/PUT/PATCH/DELETE /templates/{id}、POST copy、GET usage、
  POST toggle-favorite、POST validate、GET/POST/DELETE /categories、GET /tags/list
- 保留内部默认模板兜底 _get_or_create_default_template_id 及 CreateTemplateUseCase
- 删除对应 response_model 中不再使用的类(Copy/Update/Validate/Category/Usage/Favorite 等)
- 清理测试:删除集成测试 test_template_categories_api.py,更新 3 个单测适配新 clip_count 语义

DB:未涉及 schema 变更(models 本就无 is_favorite/usage_count 等列),跳过 migration。
新增 scripts/cleanup_e2e_test_data.sql 供运维在 staging DB 手动清理 e2e-gen-*/asset-create_* 账号残留模板数据。

单测:15128 passed, 28 skipped(全量 tests/unit/)
fix(#1900): list_templates 返回 total 总数(修复分页)
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 2s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 2s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 1m59s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 2m7s
CI/CD Pipeline / Validate - Style (pull_request) Successful in 2m53s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 2m55s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m6s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 3m3s
CI/CD Pipeline / Validate - Security (pull_request) Successful in 6m21s
AI Code Review / AI Code Review (pull_request) Successful in 6m31s
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Successful in 6m46s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 10m38s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 14m39s
CI/CD Pipeline / CI Gate (pull_request) Successful in 1s
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
ACR Cleanup / ACR Image Cleanup (pull_request_target) Successful in 13s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 33s
CI/CD Pipeline / Deploy Production (pull_request) Failing after 31h25m36s
CI/CD Pipeline / Staging E2E Tests (pull_request) Failing after 31h40m10s
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Failing after 31h40m16s
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 31h40m22s
CI/CD Pipeline / PR Build Web Image (pull_request) Failing after 31h39m48s
CI/CD Pipeline / Build Production Worker Image (pull_request) Failing after 31h25m7s
CI/CD Pipeline / ACR Image Cleanup (pull_request) Failing after 31h39m37s
CI/CD Pipeline / Build Staging Worker Image (pull_request) Failing after 31h39m47s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Failing after 31h39m49s
CI/CD Pipeline / Staging API Integration Tests (pull_request) Failing after 31h39m37s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Failing after 31h39m41s
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Failing after 31h39m42s
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Failing after 31h39m43s
CI/CD Pipeline / Build Staging API Image (pull_request) Failing after 31h39m48s
CI/CD Pipeline / Canary Release to Production (pull_request) Failing after 31h25m3s
CI/CD Pipeline / Build Production Web Image (pull_request) Failing after 31h25m7s
CI/CD Pipeline / Check push changed paths (pull_request) Failing after 31h39m53s
CI/CD Pipeline / Build Production API Image (pull_request) Failing after 32h0m38s
CI/CD Pipeline / Build Staging Web Image (pull_request) Failing after 32h15m19s
8fadb28ea3
子代理初版用 len(items) 当 total,分页场景下第二页 total 会变小。
改为调用 CountTemplatesUseCase 走 count_by_user 返回真实总数。

🚀 预览环境已部署

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

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

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

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

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

🗑️ 预览环境已清理

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

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

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