Skip to content

Commit

Permalink
Merge pull request #799 from AI4Bharat/SN-791
Browse files Browse the repository at this point in the history
Replace updated_at with annotated_at for reports
  • Loading branch information
ishvindersethi22 authored Aug 9, 2023
2 parents 382fb6b + 5c94a65 commit b6eb351
Show file tree
Hide file tree
Showing 4 changed files with 164 additions and 126 deletions.
92 changes: 55 additions & 37 deletions backend/organizations/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def get_annotated_tasks(proj_ids, annotator, status_list, start_date, end_date):
annotated_labeled_tasks = Annotation.objects.filter(
task_id__in=annotated_task_ids,
parent_annotation_id=None,
updated_at__range=[start_date, end_date],
annotated_at__range=[start_date, end_date],
completed_by=annotator,
)

Expand All @@ -90,7 +90,7 @@ def get_reviewd_tasks(
annotated_labeled_tasks = Annotation.objects.filter(
task_id__in=annotated_task_ids,
parent_annotation_id__isnull=parent_annotation_bool,
updated_at__range=[start_date, end_date],
annotated_at__range=[start_date, end_date],
)

return annotated_labeled_tasks
Expand Down Expand Up @@ -180,7 +180,7 @@ def get_counts(
task__project_id__in=proj_ids,
annotation_status="labeled",
annotation_type=ANNOTATOR_ANNOTATION,
updated_at__range=[start_date, end_date],
annotated_at__range=[start_date, end_date],
completed_by=annotator,
)

Expand Down Expand Up @@ -238,22 +238,22 @@ def get_counts(
task__project_id__in=proj_ids,
annotation_status="skipped",
annotation_type=ANNOTATOR_ANNOTATION,
updated_at__range=[start_date, end_date],
annotated_at__range=[start_date, end_date],
completed_by=annotator,
)
all_pending_tasks_in_project = Annotation.objects.filter(
task__project_id__in=proj_ids,
annotation_status="unlabeled",
annotation_type=ANNOTATOR_ANNOTATION,
updated_at__range=[start_date, end_date],
annotated_at__range=[start_date, end_date],
completed_by=annotator,
)

all_draft_tasks_in_project = Annotation.objects.filter(
task__project_id__in=proj_ids,
annotation_status="draft",
annotation_type=ANNOTATOR_ANNOTATION,
updated_at__range=[start_date, end_date],
annotated_at__range=[start_date, end_date],
completed_by=annotator,
)

Expand Down Expand Up @@ -324,7 +324,7 @@ def get_translation_quality_reports(
],
task__project_id__in=proj_ids,
annotation_type=REVIEWER_ANNOTATION,
updated_at__range=[start_date, end_date],
annotated_at__range=[start_date, end_date],
)

parent_anno_ids_of_reviewed = [
Expand Down Expand Up @@ -1819,8 +1819,8 @@ def periodical_tasks_count(self, request, pk=None):
Annotation.objects.filter(
task_id__in=labeled_count_tasks_ids,
annotation_type=REVIEWER_ANNOTATION,
updated_at__gte=periodical_list[period],
updated_at__lt=periodical_list[period + 1],
annotated_at__gte=periodical_list[period],
annotated_at__lt=periodical_list[period + 1],
)
.exclude(annotation_status="to_be_revised")
.count()
Expand All @@ -1836,8 +1836,8 @@ def periodical_tasks_count(self, request, pk=None):
annotated_labeled_tasks_count = Annotation.objects.filter(
task_id__in=labeled_count_tasks_ids,
annotation_type=SUPER_CHECKER_ANNOTATION,
updated_at__gte=periodical_list[period],
updated_at__lt=periodical_list[period + 1],
annotated_at__gte=periodical_list[period],
annotated_at__lt=periodical_list[period + 1],
).count()
else:
tasks = Task.objects.filter(
Expand All @@ -1854,8 +1854,8 @@ def periodical_tasks_count(self, request, pk=None):
annotated_labeled_tasks_count = Annotation.objects.filter(
task_id__in=labeled_count_tasks_ids,
annotation_type=ANNOTATOR_ANNOTATION,
updated_at__gte=periodical_list[period],
updated_at__lt=periodical_list[period + 1],
annotated_at__gte=periodical_list[period],
annotated_at__lt=periodical_list[period + 1],
).count()

if metainfo == True:
Expand All @@ -1873,21 +1873,27 @@ def periodical_tasks_count(self, request, pk=None):
anno = Annotation.objects.filter(
task=each_task,
annotation_type=REVIEWER_ANNOTATION,
updated_at__gte=periodical_list[period],
updated_at__lt=periodical_list[period + 1],
annotated_at__gte=periodical_list[period],
annotated_at__lt=periodical_list[
period + 1
],
)[0]
elif each_task.task_status == "super_checked":
anno = Annotation.objects.filter(
task=each_task,
annotation_type=SUPER_CHECKER_ANNOTATION,
updated_at__gte=periodical_list[period],
updated_at__lt=periodical_list[period + 1],
annotated_at__gte=periodical_list[period],
annotated_at__lt=periodical_list[
period + 1
],
)[0]
else:
anno = Annotation.objects.filter(
id=each_task.correct_annotation.id,
updated_at__gte=periodical_list[period],
updated_at__lt=periodical_list[period + 1],
annotated_at__gte=periodical_list[period],
annotated_at__lt=periodical_list[
period + 1
],
)[0]
total_rev_duration_list.append(
get_audio_transcription_duration(anno.result)
Expand All @@ -1900,14 +1906,18 @@ def periodical_tasks_count(self, request, pk=None):
anno = Annotation.objects.filter(
task=each_task,
annotation_type=SUPER_CHECKER_ANNOTATION,
updated_at__gte=periodical_list[period],
updated_at__lt=periodical_list[period + 1],
annotated_at__gte=periodical_list[period],
annotated_at__lt=periodical_list[
period + 1
],
)[0]
else:
anno = Annotation.objects.filter(
id=each_task.correct_annotation.id,
updated_at__gte=periodical_list[period],
updated_at__lt=periodical_list[period + 1],
annotated_at__gte=periodical_list[period],
annotated_at__lt=periodical_list[
period + 1
],
)[0]
total_sup_duration_list.append(
get_audio_transcription_duration(anno.result)
Expand All @@ -1920,28 +1930,36 @@ def periodical_tasks_count(self, request, pk=None):
anno = Annotation.objects.filter(
task=each_task,
annotation_type=REVIEWER_ANNOTATION,
updated_at__gte=periodical_list[period],
updated_at__lt=periodical_list[period + 1],
annotated_at__gte=periodical_list[period],
annotated_at__lt=periodical_list[
period + 1
],
)[0]
elif each_task.task_status == "exported":
anno = Annotation.objects.filter(
id=each_task.correct_annotation.id,
updated_at__gte=periodical_list[period],
updated_at__lt=periodical_list[period + 1],
annotated_at__gte=periodical_list[period],
annotated_at__lt=periodical_list[
period + 1
],
)[0]
elif each_task.task_status == "super_checked":
anno = Annotation.objects.filter(
task=each_task,
annotation_type=SUPER_CHECKER_ANNOTATION,
updated_at__gte=periodical_list[period],
updated_at__lt=periodical_list[period + 1],
annotated_at__gte=periodical_list[period],
annotated_at__lt=periodical_list[
period + 1
],
)[0]
else:
anno = Annotation.objects.filter(
task=each_task,
annotation_type=ANNOTATOR_ANNOTATION,
updated_at__gte=periodical_list[period],
updated_at__lt=periodical_list[period + 1],
annotated_at__gte=periodical_list[period],
annotated_at__lt=periodical_list[
period + 1
],
)[0]
total_ann_duration_list.append(
get_audio_transcription_duration(anno.result)
Expand Down Expand Up @@ -1987,8 +2005,8 @@ def periodical_tasks_count(self, request, pk=None):
annotated_labeled_tasks = Annotation.objects.filter(
task_id__in=labeled_count_tasks_ids,
annotation_type=REVIEWER_ANNOTATION,
updated_at__gte=periodical_list[period],
updated_at__lt=periodical_list[period + 1],
annotated_at__gte=periodical_list[period],
annotated_at__lt=periodical_list[period + 1],
)
for each_task in annotated_labeled_tasks:
try:
Expand All @@ -2005,8 +2023,8 @@ def periodical_tasks_count(self, request, pk=None):
annotated_labeled_tasks = Annotation.objects.filter(
task_id__in=labeled_count_tasks_ids,
annotation_type=SUPER_CHECKER_ANNOTATION,
updated_at__gte=periodical_list[period],
updated_at__lt=periodical_list[period + 1],
annotated_at__gte=periodical_list[period],
annotated_at__lt=periodical_list[period + 1],
)
for each_task in annotated_labeled_tasks:
try:
Expand All @@ -2023,8 +2041,8 @@ def periodical_tasks_count(self, request, pk=None):
annotated_labeled_tasks = Annotation.objects.filter(
task_id__in=labeled_count_tasks_ids,
annotation_type=ANNOTATOR_ANNOTATION,
updated_at__gte=periodical_list[period],
updated_at__lt=periodical_list[period + 1],
annotated_at__gte=periodical_list[period],
annotated_at__lt=periodical_list[period + 1],
)
for each_task in annotated_labeled_tasks:
try:
Expand Down
Loading

0 comments on commit b6eb351

Please sign in to comment.