You've already forked DataMate
feat(annotation): 添加标注任务进行中数据显示功能
- 新增 AnnotationTaskListItem 和相关类型定义 - 在前端页面中添加标注中列显示进行中的标注数据量 - 更新数据获取逻辑以支持进行中标注数量统计 - 修改后端服务层添加 in_progress_count 字段映射 - 优化类型安全和代码结构设计
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user