From f656efffeeeb78b3d7fac115446cc49b0b7bc6f5 Mon Sep 17 00:00:00 2001 From: Ishvinder Sethi Date: Wed, 23 Aug 2023 07:10:53 +0530 Subject: [PATCH 1/3] Workspace level project reports changes --- backend/workspaces/views.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/backend/workspaces/views.py b/backend/workspaces/views.py index c8293353c..8502d19ff 100644 --- a/backend/workspaces/views.py +++ b/backend/workspaces/views.py @@ -1269,7 +1269,7 @@ def project_analytics(self, request, pk=None): for each_task in labeled_tasks: try: annotate_annotation = Annotation.objects.filter( - task=each_task, annotation_type=ANNOTATOR_ANNOTATION + task=each_task, annotation_type=ANNOTATOR_ANNOTATION, annotation_status__in=["labeled"] )[0] total_duration_annotated_count_list.append( get_audio_transcription_duration( @@ -1282,7 +1282,8 @@ def project_analytics(self, request, pk=None): for each_task in reviewed_tasks: try: review_annotation = Annotation.objects.filter( - task=each_task, annotation_type=REVIEWER_ANNOTATION + task=each_task, annotation_type=REVIEWER_ANNOTATION, annotation_status__in=["accepted", "accepted_with_minor_changes", "accepted_with_major_changes"] + )[0 )[0] total_duration_reviewed_count_list.append( get_audio_transcription_duration( @@ -1311,7 +1312,8 @@ def project_analytics(self, request, pk=None): for each_task in superchecked_tasks: try: supercheck_annotation = Annotation.objects.filter( - task=each_task, annotation_type=SUPER_CHECKER_ANNOTATION + task=each_task, annotation_type=SUPER_CHECKER_ANNOTATION, annotation_status__in=["validated", "validated_with_changes"] + )[0 )[0] total_duration_superchecked_count_list.append( get_audio_transcription_duration( From c5d6cd25b2a20af1a6822f3a74fe4a5ddfe70bbe Mon Sep 17 00:00:00 2001 From: Kunal Tiwary Date: Wed, 23 Aug 2023 14:08:41 +0530 Subject: [PATCH 2/3] small_fixes --- backend/utils/convert_result_to_chitralekha_format.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/backend/utils/convert_result_to_chitralekha_format.py b/backend/utils/convert_result_to_chitralekha_format.py index 3e60317cf..302990ea5 100644 --- a/backend/utils/convert_result_to_chitralekha_format.py +++ b/backend/utils/convert_result_to_chitralekha_format.py @@ -1,7 +1,14 @@ def create_memory(result): memory = {} for i in range(len(result)): - key = result[i]["id"] + try: + key = result[i]["id"] + except KeyError: + print( + f"The entry number {i} is not having an id hence cannot be converted to CL_format" + ) + del result[i] + continue if key not in memory: memory[key] = {"labels_dict_idx": -1, "text_dict_idx": -1} if result[i]["type"] == "labels": @@ -12,6 +19,8 @@ def create_memory(result): def convert_result_to_chitralekha_format(result, ann_id): + if len(result) == 1 and result[0] == {}: + return [{}] memory = create_memory(result) modified_result = [] count = 1 From e2db1bcec3751ec0e62f0724b63d47df331c3ae0 Mon Sep 17 00:00:00 2001 From: Kunal Tiwary Date: Wed, 23 Aug 2023 14:16:51 +0530 Subject: [PATCH 3/3] black changes --- backend/workspaces/views.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/backend/workspaces/views.py b/backend/workspaces/views.py index 8502d19ff..39e85ed81 100644 --- a/backend/workspaces/views.py +++ b/backend/workspaces/views.py @@ -1269,7 +1269,9 @@ def project_analytics(self, request, pk=None): for each_task in labeled_tasks: try: annotate_annotation = Annotation.objects.filter( - task=each_task, annotation_type=ANNOTATOR_ANNOTATION, annotation_status__in=["labeled"] + task=each_task, + annotation_type=ANNOTATOR_ANNOTATION, + annotation_status__in=["labeled"], )[0] total_duration_annotated_count_list.append( get_audio_transcription_duration( @@ -1282,8 +1284,13 @@ def project_analytics(self, request, pk=None): for each_task in reviewed_tasks: try: review_annotation = Annotation.objects.filter( - task=each_task, annotation_type=REVIEWER_ANNOTATION, annotation_status__in=["accepted", "accepted_with_minor_changes", "accepted_with_major_changes"] - )[0 + task=each_task, + annotation_type=REVIEWER_ANNOTATION, + annotation_status__in=[ + "accepted", + "accepted_with_minor_changes", + "accepted_with_major_changes", + ], )[0] total_duration_reviewed_count_list.append( get_audio_transcription_duration( @@ -1312,8 +1319,12 @@ def project_analytics(self, request, pk=None): for each_task in superchecked_tasks: try: supercheck_annotation = Annotation.objects.filter( - task=each_task, annotation_type=SUPER_CHECKER_ANNOTATION, annotation_status__in=["validated", "validated_with_changes"] - )[0 + task=each_task, + annotation_type=SUPER_CHECKER_ANNOTATION, + annotation_status__in=[ + "validated", + "validated_with_changes", + ], )[0] total_duration_superchecked_count_list.append( get_audio_transcription_duration(