From f917091792f734ada91d67c473dde1d5c34b9e81 Mon Sep 17 00:00:00 2001 From: gary Date: Fri, 21 Feb 2025 14:46:06 +0800 Subject: [PATCH] fix: remove owner_id param in list pre_annotations (#192) --- ...2eb983c9a254_add_collaborators_and_updaters.py | 15 +++++++++++++++ .../adapter/persistence/crud_pre_annotation.py | 2 +- .../internal/domain/models/task_collaborator.py | 4 ---- .../internal/domain/models/task_sample_updater.py | 3 --- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/labelu/alembic_labelu/versions/2eb983c9a254_add_collaborators_and_updaters.py b/labelu/alembic_labelu/versions/2eb983c9a254_add_collaborators_and_updaters.py index 706df3b7..ce761d5a 100644 --- a/labelu/alembic_labelu/versions/2eb983c9a254_add_collaborators_and_updaters.py +++ b/labelu/alembic_labelu/versions/2eb983c9a254_add_collaborators_and_updaters.py @@ -49,6 +49,13 @@ def upgrade() -> None: ) # Performances index + is_index_2_exist = op.execute( + "SHOW INDEX FROM task_collaborator WHERE Key_name = 'ix_task_collaborator_task_id';" + ).fetchone() + + if is_index_2_exist: + return + op.create_index( 'ix_task_collaborator_task_id', 'task_collaborator', @@ -97,6 +104,14 @@ def upgrade() -> None: ) # Performances index + # check if the index is already exists + is_index_exist = op.execute( + "SHOW INDEX FROM task_sample_updater WHERE Key_name = 'ix_task_sample_updater_sample_id';" + ).fetchone() + + if is_index_exist: + return + op.create_index( 'ix_task_sample_updater_sample_id', 'task_sample_updater', diff --git a/labelu/internal/adapter/persistence/crud_pre_annotation.py b/labelu/internal/adapter/persistence/crud_pre_annotation.py index 3a4cfae6..83fd79df 100644 --- a/labelu/internal/adapter/persistence/crud_pre_annotation.py +++ b/labelu/internal/adapter/persistence/crud_pre_annotation.py @@ -79,7 +79,7 @@ def list_by_task_id_and_file_id(db: Session, task_id: int, file_id: int) -> List TaskPreAnnotation.file_id == file_id ).all() -def list_by_task_id_and_owner_id_and_sample_name(db: Session, task_id: int, owner_id: int, sample_name: str) -> List[TaskPreAnnotation]: +def list_by_task_id_and_owner_id_and_sample_name(db: Session, task_id: int, sample_name: str) -> List[TaskPreAnnotation]: """list pre annotations by task_id, owner_id and sample_name without pagination Args: diff --git a/labelu/internal/domain/models/task_collaborator.py b/labelu/internal/domain/models/task_collaborator.py index 66b3f10e..349bd6ef 100644 --- a/labelu/internal/domain/models/task_collaborator.py +++ b/labelu/internal/domain/models/task_collaborator.py @@ -23,7 +23,3 @@ class TaskCollaborator(Base): default=datetime.now, comment="Time a task collaborator was created" ) - - Index("ix_task_collaborator_task_id", task_id) - Index("ix_task_collaborator_user_id", user_id) - Index("ix_task_created_by_deleted_at", task_id, user_id) diff --git a/labelu/internal/domain/models/task_sample_updater.py b/labelu/internal/domain/models/task_sample_updater.py index 6bbb9251..d414a161 100644 --- a/labelu/internal/domain/models/task_sample_updater.py +++ b/labelu/internal/domain/models/task_sample_updater.py @@ -25,6 +25,3 @@ class TaskSampleUpdater(Base): nullable=False, comment="created time" ) - - Index("ix_task_sample_updater_sample_id", sample_id) - Index("ix_task_sample_updater_user_id", user_id)