forked from HumanSignal/label-studio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: DEV-2147: Calculate only requested fields (HumanSignal#2231)
* feat: DEV-2147: Calculate only requested fields * Review fixes (DEV-2147) * Remove unused function (DEV-2147) * Pretty fixes Co-authored-by: makseq-ubnt <[email protected]>
- Loading branch information
1 parent
5550988
commit cfa097c
Showing
5 changed files
with
136 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from django.db.models import Count, Q | ||
|
||
|
||
def annotate_task_number(queryset): | ||
return queryset.annotate(task_number=Count('tasks', distinct=True)) | ||
|
||
|
||
def annotate_finished_task_number(queryset): | ||
return queryset.annotate(finished_task_number=Count('tasks', distinct=True, filter=Q(tasks__is_labeled=True))) | ||
|
||
|
||
def annotate_total_predictions_number(queryset): | ||
return queryset.annotate(total_predictions_number=Count('tasks__predictions', distinct=True)) | ||
|
||
|
||
def annotate_total_annotations_number(queryset): | ||
return queryset.annotate(total_annotations_number=Count( | ||
'tasks__annotations__id', distinct=True, filter=Q(tasks__annotations__was_cancelled=False) | ||
)) | ||
|
||
|
||
def annotate_num_tasks_with_annotations(queryset): | ||
return queryset.annotate(num_tasks_with_annotations=Count( | ||
'tasks__id', | ||
distinct=True, | ||
filter=Q(tasks__annotations__isnull=False) | ||
& Q(tasks__annotations__ground_truth=False) | ||
& Q(tasks__annotations__was_cancelled=False) | ||
& Q(tasks__annotations__result__isnull=False), | ||
)) | ||
|
||
|
||
def annotate_useful_annotation_number(queryset): | ||
return queryset.annotate(useful_annotation_number=Count( | ||
'tasks__annotations__id', | ||
distinct=True, | ||
filter=Q(tasks__annotations__was_cancelled=False) | ||
& Q(tasks__annotations__ground_truth=False) | ||
& Q(tasks__annotations__result__isnull=False), | ||
)) | ||
|
||
|
||
def annotate_ground_truth_number(queryset): | ||
return queryset.annotate(ground_truth_number=Count( | ||
'tasks__annotations__id', distinct=True, filter=Q(tasks__annotations__ground_truth=True) | ||
)) | ||
|
||
|
||
def annotate_skipped_annotations_number(queryset): | ||
return queryset.annotate(skipped_annotations_number=Count( | ||
'tasks__annotations__id', distinct=True, filter=Q(tasks__annotations__was_cancelled=True) | ||
)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
|
||
test_name: test_project_id | ||
|
||
strict: True | ||
|
||
marks: | ||
- usefixtures: | ||
- django_live_url | ||
|
||
stages: | ||
- id: signup | ||
type: ref | ||
- id: get_user_token | ||
type: ref | ||
- id: create_project | ||
name: Create project | ||
request: | ||
url: "{django_live_url}/api/projects" | ||
json: | ||
title: create_batch_tasks_assignments | ||
label_config: <View><Text name="text" value="$text"/><Choices name="label" toName="text"><Choice value="pos"/><Choice value="neg"/></Choices></View> | ||
is_published: true | ||
method: POST | ||
headers: | ||
content-type: application/json | ||
response: | ||
status_code: 201 | ||
save: | ||
json: | ||
project_pk: id | ||
- name: get_only_id | ||
request: | ||
method: GET | ||
url: '{django_live_url}/api/projects/{project_pk}?include=id' | ||
response: | ||
status_code: 200 | ||
json: | ||
id: !int "{project_pk}" |