feat(annotation): 添加标注任务进行中数据显示功能

- 新增 AnnotationTaskListItem 和相关类型定义
- 在前端页面中添加标注中列显示进行中的标注数据量
- 更新数据获取逻辑以支持进行中标注数量统计
- 修改后端服务层添加 in_progress_count 字段映射
- 优化类型安全和代码结构设计
This commit is contained in:
2026-01-31 17:14:23 +08:00
parent 5d8d25ca8c
commit 4a3e466210
4 changed files with 130 additions and 30 deletions

View File

@@ -61,6 +61,7 @@ class DatasetMappingResponse(BaseModel):
)
total_count: int = Field(0, alias="totalCount", description="数据集总数据量")
annotated_count: int = Field(0, alias="annotatedCount", description="已标注数据量")
in_progress_count: int = Field(0, alias="inProgressCount", description="分段标注中数据量")
created_at: datetime = Field(..., alias="createdAt", description="创建时间")
updated_at: Optional[datetime] = Field(None, alias="updatedAt", description="更新时间")
deleted_at: Optional[datetime] = Field(None, alias="deletedAt", description="删除时间")

View File

@@ -8,6 +8,7 @@ import uuid
from app.core.logging import get_logger
from app.db.models import LabelingProject, AnnotationTemplate, AnnotationResult, LabelingProjectFile
from app.db.models.annotation_management import ANNOTATION_STATUS_IN_PROGRESS
from app.db.models.dataset_management import Dataset, DatasetFiles
from app.module.annotation.schema import (
DatasetMappingCreateRequest,
@@ -40,7 +41,7 @@ class DatasetMappingService:
self,
project_id: str,
dataset_id: str
) -> Tuple[int, int]:
) -> Tuple[int, int, int]:
"""
获取项目的统计数据
@@ -49,7 +50,7 @@ class DatasetMappingService:
dataset_id: 数据集ID
Returns:
(total_count, annotated_count) 元组
(total_count, annotated_count, in_progress_count) 元组
"""
# 获取标注项目快照数据量(只统计快照内的文件)
total_result = await self.db.execute(
@@ -71,7 +72,16 @@ class DatasetMappingService:
)
annotated_count = int(annotated_result.scalar() or 0)
return total_count, annotated_count
# 获取分段标注中数据量(标注状态为 IN_PROGRESS)
in_progress_result = await self.db.execute(
select(func.count(func.distinct(AnnotationResult.file_id))).where(
AnnotationResult.project_id == project_id,
AnnotationResult.annotation_status == ANNOTATION_STATUS_IN_PROGRESS,
)
)
in_progress_count = int(in_progress_result.scalar() or 0)
return total_count, annotated_count, in_progress_count
async def _to_response_from_row(
self,
@@ -110,7 +120,7 @@ class DatasetMappingService:
logger.debug(f"Included template details for template_id: {template_id}")
# 获取统计数据
total_count, annotated_count = await self._get_project_stats(
total_count, annotated_count, in_progress_count = await self._get_project_stats(
mapping.id, mapping.dataset_id
)
@@ -127,6 +137,7 @@ class DatasetMappingService:
"segmentation_enabled": segmentation_enabled,
"total_count": total_count,
"annotated_count": annotated_count,
"in_progress_count": in_progress_count,
"created_at": mapping.created_at,
"updated_at": mapping.updated_at,
"deleted_at": mapping.deleted_at,
@@ -177,9 +188,9 @@ class DatasetMappingService:
logger.debug(f"Included template details for template_id: {template_id}")
# 获取统计数据
total_count, annotated_count = 0, 0
total_count, annotated_count, in_progress_count = 0, 0, 0
if dataset_id:
total_count, annotated_count = await self._get_project_stats(
total_count, annotated_count, in_progress_count = await self._get_project_stats(
mapping.id, dataset_id
)
@@ -197,6 +208,7 @@ class DatasetMappingService:
"segmentation_enabled": segmentation_enabled,
"total_count": total_count,
"annotated_count": annotated_count,
"in_progress_count": in_progress_count,
"created_at": mapping.created_at,
"updated_at": mapping.updated_at,
"deleted_at": mapping.deleted_at,