You've already forked DataMate
feat(annotation): 添加标注项目文件快照功能
- 新增 LabelingProjectFile 模型用于存储标注项目的文件快照 - 在创建标注项目时记录关联的文件快照数据 - 更新查询逻辑以基于项目快照过滤文件列表 - 优化导出统计功能使用快照数据进行计算 - 添加数据库表结构支持项目文件快照关系
This commit is contained in:
@@ -23,7 +23,7 @@ from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.core.config import settings
|
||||
from app.core.logging import get_logger
|
||||
from app.db.models import AnnotationResult, Dataset, DatasetFiles, LabelingProject
|
||||
from app.db.models import AnnotationResult, Dataset, DatasetFiles, LabelingProject, LabelingProjectFile
|
||||
from app.module.annotation.config import LabelStudioTagConfig
|
||||
from app.module.annotation.schema.editor import (
|
||||
EditorProjectInfo,
|
||||
@@ -436,14 +436,18 @@ class AnnotationEditorService:
|
||||
exclude_source_documents if exclude_source_documents is not None else True
|
||||
)
|
||||
|
||||
base_conditions = [DatasetFiles.dataset_id == project.dataset_id]
|
||||
base_conditions = [
|
||||
LabelingProjectFile.project_id == project_id,
|
||||
DatasetFiles.dataset_id == project.dataset_id,
|
||||
]
|
||||
if should_exclude_source_documents:
|
||||
base_conditions.append(~self._build_source_document_filter())
|
||||
|
||||
count_result = await self.db.execute(
|
||||
select(func.count()).select_from(DatasetFiles).where(
|
||||
*base_conditions
|
||||
)
|
||||
select(func.count())
|
||||
.select_from(LabelingProjectFile)
|
||||
.join(DatasetFiles, LabelingProjectFile.file_id == DatasetFiles.id)
|
||||
.where(*base_conditions)
|
||||
)
|
||||
total = int(count_result.scalar() or 0)
|
||||
|
||||
@@ -453,6 +457,7 @@ class AnnotationEditorService:
|
||||
)
|
||||
files_result = await self.db.execute(
|
||||
select(DatasetFiles, AnnotationResult.id, AnnotationResult.updated_at)
|
||||
.join(LabelingProjectFile, LabelingProjectFile.file_id == DatasetFiles.id)
|
||||
.outerjoin(
|
||||
AnnotationResult,
|
||||
(AnnotationResult.file_id == DatasetFiles.id)
|
||||
@@ -827,7 +832,10 @@ class AnnotationEditorService:
|
||||
|
||||
# 校验文件归属
|
||||
file_result = await self.db.execute(
|
||||
select(DatasetFiles).where(
|
||||
select(DatasetFiles)
|
||||
.join(LabelingProjectFile, LabelingProjectFile.file_id == DatasetFiles.id)
|
||||
.where(
|
||||
LabelingProjectFile.project_id == project.id,
|
||||
DatasetFiles.id == file_id,
|
||||
DatasetFiles.dataset_id == project.dataset_id,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user