Skip to content

Commit

Permalink
sup_cumulative_tasks_count
Browse files Browse the repository at this point in the history
  • Loading branch information
KunalTiwary committed Sep 6, 2024
1 parent c6ed2fe commit c103054
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 22 deletions.
52 changes: 41 additions & 11 deletions backend/organizations/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
send_project_analytics_mail_org,
send_user_analytics_mail_org,
)
from utils.filter_tasks_by_ann_type import filter_tasks_by_ann_type


def get_task_count(proj_ids, status, annotator, return_count=True):
Expand Down Expand Up @@ -2743,24 +2744,41 @@ def cumulative_tasks_count(self, request, pk=None):
other_lang = []
for lang in languages:
proj_lang_filter = proj_objs.filter(tgt_language=lang)
annotation_tasks_count = 0
reviewer_task_count = 0
annotation_tasks = Task.objects.filter(
project_id__in=proj_lang_filter,
task_status__in=[
"annotated",
"reviewed",
"super_checked",
],
)
reviewer_tasks = Task.objects.filter(
project_id__in=proj_lang_filter,
project_id__project_stage__in=[REVIEW_STAGE, SUPERCHECK_STAGE],
task_status__in=["reviewed", "exported", "super_checked"],
task_status__in=["reviewed", "super_checked"],
)

annotation_tasks = Task.objects.filter(
supercheck_tasks = Task.objects.filter(
project_id__in=proj_lang_filter,
project_id__project_stage__in=[SUPERCHECK_STAGE],
task_status__in=["super_checked"],
)
annotation_tasks_exported = Task.objects.filter(
project_id__in=proj_lang_filter,
project_id__project_stage__in=[ANNOTATION_STAGE],
task_status__in=[
"annotated",
"reviewed",
"exported",
"super_checked",
],
)

reviewer_tasks_exported = Task.objects.filter(
project_id__in=proj_lang_filter,
project_id__project_stage__in=[REVIEW_STAGE],
task_status__in=["exported"],
)
supercheck_tasks_exported = Task.objects.filter(
project_id__in=proj_lang_filter,
project_id__project_stage__in=[SUPERCHECK_STAGE],
task_status__in=["exported"],
)
if metainfo == True:
result = {}

Expand Down Expand Up @@ -2975,14 +2993,23 @@ def cumulative_tasks_count(self, request, pk=None):
}

else:
reviewer_task_count = reviewer_tasks.count()
reviewer_task_count = (
reviewer_tasks.count() + reviewer_tasks_exported.count()
)

annotation_tasks_count = annotation_tasks.count()
annotation_tasks_count = (
annotation_tasks.count() + annotation_tasks_exported.count()
)

supercheck_tasks_count = (
supercheck_tasks.count() + supercheck_tasks_exported.count()
)

result = {
"language": lang,
"ann_cumulative_tasks_count": annotation_tasks_count,
"rew_cumulative_tasks_count": reviewer_task_count,
"sup_cumulative_tasks_count": supercheck_tasks_count,
}

if lang == None or lang == "":
Expand All @@ -2992,6 +3019,7 @@ def cumulative_tasks_count(self, request, pk=None):

ann_task_count = 0
rew_task_count = 0
sup_task_count = 0
ann_word_count = 0
rew_word_count = 0
ann_aud_dur = 0
Expand All @@ -3006,6 +3034,7 @@ def cumulative_tasks_count(self, request, pk=None):
if metainfo != True:
ann_task_count += dat["ann_cumulative_tasks_count"]
rew_task_count += dat["rew_cumulative_tasks_count"]
sup_task_count += dat["sup_cumulative_tasks_count"]
else:
if project_type in get_audio_project_types():
ann_aud_dur += convert_hours_to_seconds(
Expand Down Expand Up @@ -3048,6 +3077,7 @@ def cumulative_tasks_count(self, request, pk=None):
"language": "Others",
"ann_cumulative_tasks_count": ann_task_count,
"rew_cumulative_tasks_count": rew_task_count,
"sup_cumulative_tasks_count": sup_task_count,
}
else:
if project_type in get_audio_project_types():
Expand Down
47 changes: 47 additions & 0 deletions backend/utils/filter_tasks_by_ann_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from tasks.models import (
Annotation,
ANNOTATOR_ANNOTATION,
REVIEWER_ANNOTATION,
SUPER_CHECKER_ANNOTATION,
LABELED,
ACCEPTED,
ACCEPTED_WITH_MINOR_CHANGES,
ACCEPTED_WITH_MAJOR_CHANGES,
VALIDATED,
VALIDATED_WITH_CHANGES,
)


def filter_tasks_by_ann_type(annotation_tasks, reviewer_tasks, supercheck_tasks):
filtered_annotation_tasks, filtered_reviewer_tasks, filtered_supercheck_tasks = (
[],
[],
[],
)
for a in annotation_tasks:
anno = Annotation.objects.filter(
task=a, annotation_type=ANNOTATOR_ANNOTATION, annotation_status=LABELED
)[0]
if anno:
filtered_annotation_tasks.append(a)
for r in reviewer_tasks:
anno = Annotation.objects.filter(
task=r,
annotation_type=REVIEWER_ANNOTATION,
annotation_status__in=[
ACCEPTED,
ACCEPTED_WITH_MINOR_CHANGES,
ACCEPTED_WITH_MAJOR_CHANGES,
],
)[0]
if anno:
filtered_reviewer_tasks.append(r)
for s in supercheck_tasks:
anno = Annotation.objects.filter(
task=s,
annotation_type=SUPER_CHECKER_ANNOTATION,
annotation_status__in=[VALIDATED, VALIDATED_WITH_CHANGES],
)[0]
if anno:
filtered_supercheck_tasks.append(s)
return filtered_annotation_tasks, filtered_reviewer_tasks, filtered_supercheck_tasks
52 changes: 41 additions & 11 deletions backend/workspaces/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
get_review_reports,
get_supercheck_reports,
)

from utils.filter_tasks_by_ann_type import filter_tasks_by_ann_type

# Create your views here.

Expand Down Expand Up @@ -1404,23 +1404,41 @@ def cumulative_tasks_count_all(self, request, pk=None):
other_lang = []
for lang in languages:
proj_lang_filter = proj_objs.filter(tgt_language=lang)
annotation_tasks_count = 0
reviewer_task_count = 0
annotation_tasks = Task.objects.filter(
project_id__in=proj_lang_filter,
task_status__in=[
"annotated",
"reviewed",
"super_checked",
],
)
reviewer_tasks = Task.objects.filter(
project_id__in=proj_lang_filter,
project_id__project_stage__in=[REVIEW_STAGE, SUPERCHECK_STAGE],
task_status__in=["reviewed", "exported", "super_checked"],
task_status__in=["reviewed", "super_checked"],
)

annotation_tasks = Task.objects.filter(
supercheck_tasks = Task.objects.filter(
project_id__in=proj_lang_filter,
project_id__project_stage__in=[SUPERCHECK_STAGE],
task_status__in=["super_checked"],
)
annotation_tasks_exported = Task.objects.filter(
project_id__in=proj_lang_filter,
project_id__project_stage__in=[ANNOTATION_STAGE],
task_status__in=[
"annotated",
"reviewed",
"exported",
"super_checked",
],
)
reviewer_tasks_exported = Task.objects.filter(
project_id__in=proj_lang_filter,
project_id__project_stage__in=[REVIEW_STAGE],
task_status__in=["exported"],
)
supercheck_tasks_exported = Task.objects.filter(
project_id__in=proj_lang_filter,
project_id__project_stage__in=[SUPERCHECK_STAGE],
task_status__in=["exported"],
)

if metainfo == True:
result = {}
Expand Down Expand Up @@ -1636,14 +1654,23 @@ def cumulative_tasks_count_all(self, request, pk=None):
}

else:
reviewer_task_count = reviewer_tasks.count()
reviewer_task_count = (
reviewer_tasks.count() + reviewer_tasks_exported.count()
)

annotation_tasks_count = annotation_tasks.count()
annotation_tasks_count = (
annotation_tasks.count() + annotation_tasks_exported.count()
)

supercheck_tasks_count = (
supercheck_tasks.count() + supercheck_tasks_exported.count()
)

result = {
"language": lang,
"ann_cumulative_tasks_count": annotation_tasks_count,
"rew_cumulative_tasks_count": reviewer_task_count,
"sup_cumulative_tasks_count": supercheck_tasks_count,
}

if lang == None or lang == "":
Expand All @@ -1653,6 +1680,7 @@ def cumulative_tasks_count_all(self, request, pk=None):

ann_task_count = 0
rew_task_count = 0
sup_task_count = 0
ann_word_count = 0
rew_word_count = 0
ann_aud_dur = 0
Expand All @@ -1667,6 +1695,7 @@ def cumulative_tasks_count_all(self, request, pk=None):
if metainfo != True:
ann_task_count += dat["ann_cumulative_tasks_count"]
rew_task_count += dat["rew_cumulative_tasks_count"]
sup_task_count += dat["sup_cumulative_tasks_count"]
else:
if project_type in get_audio_project_types():
ann_aud_dur += convert_hours_to_seconds(
Expand Down Expand Up @@ -1710,6 +1739,7 @@ def cumulative_tasks_count_all(self, request, pk=None):
"language": "Others",
"ann_cumulative_tasks_count": ann_task_count,
"rew_cumulative_tasks_count": rew_task_count,
"sup_cumulative_tasks_count": sup_task_count,
}
else:
if project_type in get_audio_project_types():
Expand Down

0 comments on commit c103054

Please sign in to comment.