From d5d8f4bfdbabb3d5304970ee9fac32f7769d8a54 Mon Sep 17 00:00:00 2001 From: CI Bot Date: Mon, 20 Jul 2026 21:36:15 +0800 Subject: [PATCH] =?UTF-8?q?feat(phase3):=20=E6=B8=85=E7=90=86EditPlan?= =?UTF-8?q?=E8=A1=A8=E5=86=97=E4=BD=99=E5=AD=97=E6=AE=B5result=5Fcount?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 删除EditPlan领域模型/仓储/DB模型中的result_count字段 - 清理worker中对plan.result_count的写入 - 创建048 migration删除edit_plans.result_count列 - 该字段为剪辑计划独立功能遗留,生成结果数由generation_tasks承载 - net: -6行 + 1 migration --- .../048_cleanup_editplan_redundant_fields.py | 37 +++++++++++++++++++ .../worker_app/tasks/edit_plan_generation.py | 2 - .../sqlalchemy_impl/edit_plan_repository.py | 3 -- packages/adapters/sqlalchemy_impl/models.py | 1 - packages/domain/edit_plan.py | 3 -- 5 files changed, 37 insertions(+), 9 deletions(-) create mode 100755 alembic/versions/048_cleanup_editplan_redundant_fields.py diff --git a/alembic/versions/048_cleanup_editplan_redundant_fields.py b/alembic/versions/048_cleanup_editplan_redundant_fields.py new file mode 100755 index 000000000..db32c426c --- /dev/null +++ b/alembic/versions/048_cleanup_editplan_redundant_fields.py @@ -0,0 +1,37 @@ +"""Phase 3 - 清理 EditPlan 表冗余字段 + +Revision ID: 048 +Revises: 047 +Create Date: 2026-07-21 + +Changes: +1. 删除 edit_plans.result_count 字段(剪辑计划独立功能遗留,模板草稿不用, + 生成结果数由 generation_tasks.result_count 承载) +""" + +import sqlalchemy as sa + +from alembic import op + +revision = "048_cleanup_editplan_redundant_fields" +down_revision = "047_template_versioning" +branch_labels = None +depends_on = None + + +def upgrade() -> None: + # 删除 result_count 字段(剪辑计划独立功能遗留字段) + op.drop_column("edit_plans", "result_count") + + +def downgrade() -> None: + # 回滚:恢复 result_count 字段,默认值 0 + op.add_column( + "edit_plans", + sa.Column( + "result_count", + sa.Integer, + nullable=False, + server_default="0", + ), + ) diff --git a/apps/worker/worker_app/tasks/edit_plan_generation.py b/apps/worker/worker_app/tasks/edit_plan_generation.py index 7ecbe3e8c..c1f52ecac 100755 --- a/apps/worker/worker_app/tasks/edit_plan_generation.py +++ b/apps/worker/worker_app/tasks/edit_plan_generation.py @@ -142,8 +142,6 @@ def _finalize_render_success( plan.config["rendered_storage_key"] = storage_key if hasattr(plan, "total_duration") and duration > 0: plan.total_duration = duration - if hasattr(plan, "result_count"): - plan.result_count = 1 plan.mark_completed() plan_repo.update(plan) diff --git a/packages/adapters/sqlalchemy_impl/edit_plan_repository.py b/packages/adapters/sqlalchemy_impl/edit_plan_repository.py index 871fd88ed..ad6c87eb5 100755 --- a/packages/adapters/sqlalchemy_impl/edit_plan_repository.py +++ b/packages/adapters/sqlalchemy_impl/edit_plan_repository.py @@ -100,7 +100,6 @@ class SQLAlchemyEditPlanRepository: name=plan.name, status=plan.status, total_duration=plan.total_duration, - result_count=plan.result_count, source_edit_plan_id=plan.source_edit_plan_id or None, project_id=plan.project_id or "", created_by_user_id=plan.created_by_user_id or "", @@ -120,7 +119,6 @@ class SQLAlchemyEditPlanRepository: model.name = plan.name model.status = plan.status model.total_duration = plan.total_duration - model.result_count = plan.result_count model.source_edit_plan_id = plan.source_edit_plan_id or None model.project_id = plan.project_id or "" model.created_by_user_id = plan.created_by_user_id or "" @@ -154,7 +152,6 @@ class SQLAlchemyEditPlanRepository: name=model.name, status=EditPlanStatus(model.status) if model.status else EditPlanStatus.DRAFT, total_duration=model.total_duration or 0.0, - result_count=int(model.result_count or 0), source_edit_plan_id=model.source_edit_plan_id or "", project_id=model.project_id or "", created_by_user_id=model.created_by_user_id or "", diff --git a/packages/adapters/sqlalchemy_impl/models.py b/packages/adapters/sqlalchemy_impl/models.py index d4f209a5c..ff64a71d0 100755 --- a/packages/adapters/sqlalchemy_impl/models.py +++ b/packages/adapters/sqlalchemy_impl/models.py @@ -172,7 +172,6 @@ class EditPlanModel(Base): name = Column(String(200), nullable=False) status = Column(String(20), nullable=False, default="draft", index=True) total_duration = Column(Float, nullable=False, default=0.0) - result_count = Column(Integer, nullable=False, default=0) config = Column(JSON, nullable=False, default=dict) source_edit_plan_id = Column(String(36), nullable=True, index=True) project_id = Column(String(36), nullable=False, default="", index=True) diff --git a/packages/domain/edit_plan.py b/packages/domain/edit_plan.py index 7b7467da6..4eec3e915 100755 --- a/packages/domain/edit_plan.py +++ b/packages/domain/edit_plan.py @@ -42,7 +42,6 @@ class EditPlan: name: str status: EditPlanStatus = EditPlanStatus.DRAFT total_duration: float = 0.0 - result_count: int = 0 source_edit_plan_id: str = "" project_id: str = "" created_by_user_id: str = "" @@ -58,7 +57,6 @@ class EditPlan: *, config: dict[str, Any] | None = None, total_duration: float = 0.0, - result_count: int = 0, source_edit_plan_id: str = "", project_id: str = "", created_by_user_id: str = "", @@ -75,7 +73,6 @@ class EditPlan: name=clean_name, status=EditPlanStatus.DRAFT, total_duration=total_duration, - result_count=result_count, source_edit_plan_id=source_edit_plan_id.strip(), project_id=project_id.strip(), created_by_user_id=created_by_user_id.strip(),