43366f290c
Deploy / Build Production Runtime Images (push) Has been skipped
Deploy / Deploy Production (push) Has been skipped
Deploy / Production Browser E2E (push) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 181h43m15s
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Failing after 181h43m19s
Deploy / Deploy Staging (push) Failing after 181h59m26s
CI/CD Pipeline / Frontend Lint (push) Failing after 181h59m53s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 182h0m0s
- 新增 Job 领域模型(状态机、JobType/JobStatus 枚举) - 新增 JobRepository 端口 + SQLAlchemy 实现 - 新增 10 个 Use Cases(CreateJob/Submit/Progress/Complete/Fail/Retry/Cancel/Get/List/Statistics) - 新增 JobService 服务层,集成 VideoComposeService - 新增 Pydantic schemas + RESTful API 路由 - 新增 Celery compose_video 任务(含进度追踪) - 新增数据库迁移 018(jobs 表) - 新增 44 个单元测试,全部通过 - 修复状态转换:允许 pending→success(快速完成场景)
65 lines
1.5 KiB
Python
Executable File
65 lines
1.5 KiB
Python
Executable File
"""JobRepository 端口接口 — Phase 8 任务 2.10."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Protocol
|
|
|
|
from packages.domain.job import Job, JobStatus, JobType
|
|
|
|
|
|
class JobRepository(Protocol):
|
|
"""异步任务仓储接口。"""
|
|
|
|
def create(self, job: Job) -> Job:
|
|
"""持久化一个新任务。"""
|
|
...
|
|
|
|
def get(self, job_id: str) -> Job | None:
|
|
"""根据 ID 获取任务。"""
|
|
...
|
|
|
|
def update(self, job: Job) -> Job:
|
|
"""更新任务状态。"""
|
|
...
|
|
|
|
def list_by_project(
|
|
self,
|
|
project_id: str,
|
|
*,
|
|
job_type: JobType | str | None = None,
|
|
status: JobStatus | str | None = None,
|
|
limit: int = 50,
|
|
offset: int = 0,
|
|
) -> list[Job]:
|
|
"""按项目列出任务,支持类型和状态过滤。"""
|
|
...
|
|
|
|
def list_by_user(
|
|
self,
|
|
user_id: str,
|
|
*,
|
|
job_type: JobType | str | None = None,
|
|
status: JobStatus | str | None = None,
|
|
limit: int = 50,
|
|
offset: int = 0,
|
|
) -> list[Job]:
|
|
"""按创建人列出任务。"""
|
|
...
|
|
|
|
def count_by_project(
|
|
self,
|
|
project_id: str,
|
|
*,
|
|
status: JobStatus | str | None = None,
|
|
) -> int:
|
|
"""按项目统计任务数量。"""
|
|
...
|
|
|
|
def find_active_by_source(
|
|
self,
|
|
source_id: str,
|
|
job_type: JobType | str,
|
|
) -> Job | None:
|
|
"""查找关联同一业务实体的活跃任务(pending/running)。"""
|
|
...
|