From 1d340b798ce214aaad30a7c0d399decac2974649 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9=20=D0=A1=D1=83=D0=BC?= =?UTF-8?q?=D0=B8=D0=BD?= Date: Mon, 3 Mar 2025 14:55:09 +0300 Subject: [PATCH] feat: added some statistics --- services/backend/api/v1/task/schemas.py | 1 + services/backend/api/v1/user/views.py | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/services/backend/api/v1/task/schemas.py b/services/backend/api/v1/task/schemas.py index 9e73c37..3e07b92 100644 --- a/services/backend/api/v1/task/schemas.py +++ b/services/backend/api/v1/task/schemas.py @@ -33,6 +33,7 @@ class TaskOutSchema(ModelSchema): "description", "in_competition_position", "points", + "max_attempts" ] diff --git a/services/backend/api/v1/user/views.py b/services/backend/api/v1/user/views.py index 5028e87..1344e8f 100644 --- a/services/backend/api/v1/user/views.py +++ b/services/backend/api/v1/user/views.py @@ -21,7 +21,7 @@ from api.v1.user.schemas import ( TokenSchema, UserSchema, ) -from apps.task.models import CompetitionTaskSubmission +from apps.task.models import CompetitionTaskSubmission, CompetitionTask from apps.user.models import User router = Router(tags=["user"]) @@ -104,9 +104,10 @@ def get_my_stat(request): success_attempts_cnt = 0 for attempt in checked_attempts: - is_correct = attempt.result.get("correct", None) - if is_correct is None: - is_correct = attempt.result.get("total_points", 0) > 0 + if attempt.task.type == CompetitionTask.CompetitionTaskType.REVIEW: + is_correct = attempt.earned_points > 0 + else: + is_correct = attempt.result.get("correct", None) if is_correct: success_attempts_cnt += 1