Skip to content

Commit

Permalink
SN-791: combined audio project type support
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushpanwar25 committed Jul 27, 2023
1 parent 370d794 commit c92f06e
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 16 deletions.
42 changes: 33 additions & 9 deletions backend/organizations/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ def get_all_annotation_reports(
total_word_count_list.append(anno.task.data["word_count"])
except:
pass
elif project_type in get_audio_project_types():
elif (
project_type in get_audio_project_types()
or project_type == "AudioTranscription + Editing"
):
for anno in submitted_tasks:
try:
total_audio_duration_list.append(
Expand Down Expand Up @@ -90,7 +93,10 @@ def get_all_annotation_reports(
"Language": user_lang,
}

if project_type in get_audio_project_types():
if (
project_type in get_audio_project_types()
or project_type == "AudioTranscription + Editing"
):
del result["Word Count"]
else:
del result["Total Segments Duration"]
Expand Down Expand Up @@ -145,7 +151,10 @@ def get_all_review_reports(
total_word_count_list.append(anno.task.data["word_count"])
except:
pass
elif project_type in get_audio_project_types():
elif (
project_type in get_audio_project_types()
or project_type == "AudioTranscription + Editing"
):
for anno in submitted_tasks:
try:
total_audio_duration_list.append(
Expand Down Expand Up @@ -174,7 +183,10 @@ def get_all_review_reports(
"Language": user_lang,
}

if project_type in get_audio_project_types():
if (
project_type in get_audio_project_types()
or project_type == "AudioTranscription + Editing"
):
del result["Word Count"]
else:
del result["Total Segments Duration"]
Expand Down Expand Up @@ -220,7 +232,10 @@ def get_all_supercheck_reports(proj_ids, userid, project_type=None):
validated_word_count_list.append(anno.task.data["word_count"])
except:
pass
elif project_type in get_audio_project_types():
elif (
project_type in get_audio_project_types()
or project_type == "AudioTranscription + Editing"
):
for anno in submitted_tasks:
try:
validated_audio_duration_list.append(
Expand Down Expand Up @@ -253,7 +268,10 @@ def get_all_supercheck_reports(proj_ids, userid, project_type=None):
"Language": user_lang,
}

if project_type in get_audio_project_types():
if (
project_type in get_audio_project_types()
or project_type == "AudioTranscription + Editing"
):
del result["Word Count"]
else:
del result["Total Segments Duration"]
Expand All @@ -275,9 +293,15 @@ def send_user_reports_mail_org(org_id, user_id, project_type, participation_type

user = User.objects.get(id=user_id)
organization = Organization.objects.get(pk=org_id)
proj_objs = Project.objects.filter(
organization_id=org_id, project_type=project_type
)
if project_type == "AudioTranscription + Editing":
proj_objs = Project.objects.filter(
organization_id=org_id,
project_type__in=["AudioTranscription", "AudioTranscriptionEditing"],
)
else:
proj_objs = Project.objects.filter(
organization_id=org_id, project_type=project_type
)

org_anno_list = []
org_reviewer_list = []
Expand Down
40 changes: 33 additions & 7 deletions backend/workspaces/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ def get_all_annotation_reports(
total_word_count_list.append(anno.task.data["word_count"])
except:
pass
elif project_type in get_audio_project_types():
elif (
project_type in get_audio_project_types()
or project_type == "AudioTranscription + Editing"
):
for anno in submitted_tasks:
try:
total_audio_duration_list.append(
Expand Down Expand Up @@ -90,7 +93,10 @@ def get_all_annotation_reports(
"Language": user_lang,
}

if project_type in get_audio_project_types():
if (
project_type in get_audio_project_types()
or project_type == "AudioTranscription + Editing"
):
del result["Word Count"]
else:
del result["Total Segments Duration"]
Expand Down Expand Up @@ -145,7 +151,10 @@ def get_all_review_reports(
total_word_count_list.append(anno.task.data["word_count"])
except:
pass
elif project_type in get_audio_project_types():
elif (
project_type in get_audio_project_types()
or project_type == "AudioTranscription + Editing"
):
for anno in submitted_tasks:
try:
total_audio_duration_list.append(
Expand Down Expand Up @@ -174,7 +183,10 @@ def get_all_review_reports(
"Language": user_lang,
}

if project_type in get_audio_project_types():
if (
project_type in get_audio_project_types()
or project_type == "AudioTranscription + Editing"
):
del result["Word Count"]
else:
del result["Total Segments Duration"]
Expand Down Expand Up @@ -220,7 +232,10 @@ def get_all_supercheck_reports(proj_ids, userid, project_type=None):
validated_word_count_list.append(anno.task.data["word_count"])
except:
pass
elif project_type in get_audio_project_types():
elif (
project_type in get_audio_project_types()
or project_type == "AudioTranscription + Editing"
):
for anno in submitted_tasks:
try:
validated_audio_duration_list.append(
Expand Down Expand Up @@ -253,7 +268,10 @@ def get_all_supercheck_reports(proj_ids, userid, project_type=None):
"Language": user_lang,
}

if project_type in get_audio_project_types():
if (
project_type in get_audio_project_types()
or project_type == "AudioTranscription + Editing"
):
del result["Word Count"]
else:
del result["Total Segments Duration"]
Expand All @@ -275,7 +293,15 @@ def send_user_reports_mail_ws(ws_id, user_id, project_type, participation_types)

user = User.objects.get(id=user_id)
workspace = Workspace.objects.get(pk=ws_id)
proj_objs = Project.objects.filter(workspace_id=ws_id, project_type=project_type)
if project_type == "AudioTranscription + Editing":
proj_objs = Project.objects.filter(
workspace_id=ws_id,
project_type__in=["AudioTranscription", "AudioTranscriptionEditing"],
)
else:
proj_objs = Project.objects.filter(
workspace_id=ws_id, project_type=project_type
)

ws_anno_list = []
ws_reviewer_list = []
Expand Down

0 comments on commit c92f06e

Please sign in to comment.