Skip to content

Commit

Permalink
Merge pull request #932 from AI4Bharat/small_fix_get_tasks
Browse files Browse the repository at this point in the history
removed body parameters
  • Loading branch information
aparna-aa authored Dec 12, 2023
2 parents 31d8c97 + 4030d7b commit 26b8ba4
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions backend/tasks/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1071,17 +1071,14 @@ def delete_project_tasks(self, request, pk=None):
)
def get_users_recent_tasks(self, request):
try:
user_id = request.data.get("user_id")
task_type = request.data.get("task_type", "annotation")

user = request.user
task_type = request.query_params.get("task_type", "annotation")
project_id = request.query_params.get("Project ID", "")
task_id = request.query_params.get("Task ID", "")
updated_at = request.query_params.get("Updated at", "")
annotated_at = request.query_params.get("Annotated at", "")
created_at = request.query_params.get("Created at", "")

user = User.objects.get(pk=user_id)

annotations = Annotation.objects.filter(completed_by=user)
if task_type == "review":
annotations = annotations.filter(annotation_type=REVIEWER_ANNOTATION)
Expand All @@ -1093,22 +1090,37 @@ def get_users_recent_tasks(self, request):
annotations = annotations.filter(annotation_type=ANNOTATOR_ANNOTATION)

if project_id:
annotations = annotations.filter(task__project_id=project_id)
try:
annotations = annotations.filter(task__project_id=project_id)
except Exception as e:
pass

if task_id:
annotations = annotations.filter(task__id=task_id)
try:
annotations = annotations.filter(task__id=task_id)
except Exception as e:
pass

if updated_at:
date_obj = datetime.strptime(updated_at, "%d-%m-%Y")
annotations = annotations.filter(updated_at__date=date_obj.date())
try:
date_obj = datetime.strptime(updated_at, "%d-%m-%Y")
annotations = annotations.filter(updated_at__date=date_obj.date())
except Exception as e:
pass

if annotated_at:
date_obj = datetime.strptime(annotated_at, "%d-%m-%Y")
annotations = annotations.filter(annotated_at__date=date_obj.date())
try:
date_obj = datetime.strptime(annotated_at, "%d-%m-%Y")
annotations = annotations.filter(annotated_at__date=date_obj.date())
except Exception as e:
pass

if created_at:
date_obj = datetime.strptime(created_at, "%d-%m-%Y")
annotations = annotations.filter(created_at__date=date_obj.date())
try:
date_obj = datetime.strptime(created_at, "%d-%m-%Y")
annotations = annotations.filter(created_at__date=date_obj.date())
except Exception as e:
pass

annotations = annotations.order_by("-updated_at")
annotations = self.paginate_queryset(annotations)
Expand Down

0 comments on commit 26b8ba4

Please sign in to comment.