Skip to content

仅查询需要预标注数据,提升性能 #241

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions labelu/internal/adapter/persistence/crud_pre_annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,25 @@ def list_by(
results.reverse()

return results, count

def list_by_task_id_and_owner_id(db: Session, task_id: int) -> Dict[str, List[TaskPreAnnotation]]:
pre_annotations = db.query(TaskPreAnnotation).filter(
def list_by_task_id_and_owner_id_lightweight(db: Session, task_id: int, owner_id: int) -> List[Dict[str, Any]]:
pre_annotations = db.query(
TaskPreAnnotation.file_id,
TaskPreAnnotation.sample_name
).filter(
TaskPreAnnotation.task_id == task_id,
TaskPreAnnotation.deleted_at == None,
).all()
TaskPreAnnotation.created_by == owner_id
).values('file_id', 'sample_name')

return list(pre_annotations)
def list_by_task_id_and_owner_id(db: Session, task_id: int) -> Dict[str, List[TaskPreAnnotation]]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def list_by_task_id_and_owner_id(db: Session, task_id: int) -> Dict[str, List[TaskPreAnnotation]]:
def list_by_task_id_and_owner_id(db: Session, task_id: int) -> List[TaskPreAnnotation]:

pre_annotations = db.query(
TaskPreAnnotation.sample_name,
TaskPreAnnotation.file_id
).filter(
TaskPreAnnotation.task_id == task_id,
TaskPreAnnotation.deleted_at == None,
).all()

return pre_annotations

Expand Down