Skip to content

Commit

Permalink
refactor: OPTIC-920: Remove Stale Feature Flag - fflag_fix_back_LSDV_…
Browse files Browse the repository at this point in the history
…961_project_list_09022023_short (#6649)
  • Loading branch information
luarmr authored Nov 15, 2024
1 parent e4efd3c commit fc49438
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 63 deletions.
1 change: 0 additions & 1 deletion label_studio/core/feature_flags/stale_feature_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
'fflag_feat_front_lsdv_4661_full_uri_resolve_15032023_short': True,
'fflag_fix_back_LSDV_4748_annotate_task_number_14032023_short': True,
'fflag_feat_front_lsdv_4659_skipduplicates_060323_short': True,
'fflag_fix_back_LSDV_961_project_list_09022023_short': True,
'fflag_fix_font_lsdv_1148_hotkeys_namespaces_01022023_short': True,
'fflag_fix_back_lsdv_1044_check_annotations_24012023_short': False,
'fflag_feat_front_dev_4081_magic_wand_tool': True,
Expand Down
79 changes: 17 additions & 62 deletions label_studio/projects/functions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,80 +32,35 @@ def annotate_total_predictions_number(queryset):


def annotate_total_annotations_number(queryset):
if flag_set('fflag_fix_back_LSDV_961_project_list_09022023_short', user='auto'):
subquery = Annotation.objects.filter(Q(project=OuterRef('pk')) & Q(was_cancelled=False)).values('id')
return queryset.annotate(total_annotations_number=SQCount(subquery))
else:
return queryset.annotate(
total_annotations_number=Count(
'tasks__annotations__id', distinct=True, filter=Q(tasks__annotations__was_cancelled=False)
)
)
subquery = Annotation.objects.filter(Q(project=OuterRef('pk')) & Q(was_cancelled=False)).values('id')
return queryset.annotate(total_annotations_number=SQCount(subquery))


def annotate_num_tasks_with_annotations(queryset):
# @todo: check do we really need this counter?
# this function is very slow because of tasks__id and distinct

if flag_set('fflag_fix_back_LSDV_961_project_list_09022023_short', user='auto'):
subquery = (
Annotation.objects.filter(
Q(project=OuterRef('pk')) & Q(ground_truth=False) & Q(was_cancelled=False) & Q(result__isnull=False)
)
.values('task__id')
.distinct()
)
return queryset.annotate(num_tasks_with_annotations=SQCount(subquery))
else:
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),
)
subquery = (
Annotation.objects.filter(
Q(project=OuterRef('pk')) & Q(ground_truth=False) & Q(was_cancelled=False) & Q(result__isnull=False)
)
.values('task__id')
.distinct()
)
return queryset.annotate(num_tasks_with_annotations=SQCount(subquery))


def annotate_useful_annotation_number(queryset):
if flag_set('fflag_fix_back_LSDV_961_project_list_09022023_short', user='auto'):
subquery = Annotation.objects.filter(
Q(project=OuterRef('pk')) & Q(was_cancelled=False) & Q(ground_truth=False) & Q(result__isnull=False)
).values('id')
return queryset.annotate(useful_annotation_number=SQCount(subquery))
else:
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),
)
)
subquery = Annotation.objects.filter(
Q(project=OuterRef('pk')) & Q(was_cancelled=False) & Q(ground_truth=False) & Q(result__isnull=False)
).values('id')
return queryset.annotate(useful_annotation_number=SQCount(subquery))


def annotate_ground_truth_number(queryset):
if flag_set('fflag_fix_back_LSDV_961_project_list_09022023_short', user='auto'):
subquery = Annotation.objects.filter(Q(project=OuterRef('pk')) & Q(ground_truth=True)).values('id')
return queryset.annotate(ground_truth_number=SQCount(subquery))
else:
return queryset.annotate(
ground_truth_number=Count(
'tasks__annotations__id', distinct=True, filter=Q(tasks__annotations__ground_truth=True)
)
)
subquery = Annotation.objects.filter(Q(project=OuterRef('pk')) & Q(ground_truth=True)).values('id')
return queryset.annotate(ground_truth_number=SQCount(subquery))


def annotate_skipped_annotations_number(queryset):
if flag_set('fflag_fix_back_LSDV_961_project_list_09022023_short', user='auto'):
subquery = Annotation.objects.filter(Q(project=OuterRef('pk')) & Q(was_cancelled=True)).values('id')
return queryset.annotate(skipped_annotations_number=SQCount(subquery))
else:
return queryset.annotate(
skipped_annotations_number=Count(
'tasks__annotations__id', distinct=True, filter=Q(tasks__annotations__was_cancelled=True)
)
)
subquery = Annotation.objects.filter(Q(project=OuterRef('pk')) & Q(was_cancelled=True)).values('id')
return queryset.annotate(skipped_annotations_number=SQCount(subquery))

0 comments on commit fc49438

Please sign in to comment.