From 979449f1b73069819efd87e361ee55a25e48d78e Mon Sep 17 00:00:00 2001 From: Mateusz Jacniacki Date: Sun, 7 Apr 2024 19:39:20 +0200 Subject: [PATCH] Add submissions info to monitoring page * Number of submission of every kind --- .../statistics/_submissions_info.html | 22 +++++++++++++++++++ .../templates/statistics/monitoring.html | 3 +++ oioioi/statistics/views.py | 12 +++++++--- 3 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 oioioi/statistics/templates/statistics/_submissions_info.html diff --git a/oioioi/statistics/templates/statistics/_submissions_info.html b/oioioi/statistics/templates/statistics/_submissions_info.html new file mode 100644 index 000000000..c5a80d712 --- /dev/null +++ b/oioioi/statistics/templates/statistics/_submissions_info.html @@ -0,0 +1,22 @@ +{% load i18n pagination_tags %} +{% if rounds_times %} +
+

{% trans "Submission types" %}

+ + + + + + + + + {% for submission_info in submissions_info %} + + + + + {% endfor %} + +
{% trans "Kind" %} {% trans "Count" %}
{{ submission_info.kind }}{{ submission_info.total }}
+
+{% endif %} diff --git a/oioioi/statistics/templates/statistics/monitoring.html b/oioioi/statistics/templates/statistics/monitoring.html index eea7c4ffe..d82dbfaeb 100644 --- a/oioioi/statistics/templates/statistics/monitoring.html +++ b/oioioi/statistics/templates/statistics/monitoring.html @@ -10,6 +10,9 @@
{% include "statistics/_general_info.html" %}
+
+ {% include "statistics/_submissions_info.html" %} +
{% include "statistics/_attachments_info.html" %}
diff --git a/oioioi/statistics/views.py b/oioioi/statistics/views.py index 916445992..7c55033e9 100644 --- a/oioioi/statistics/views.py +++ b/oioioi/statistics/views.py @@ -2,6 +2,7 @@ from pprint import pprint from django.core.exceptions import PermissionDenied +from django.db.models import Count from django.http import Http404 from django.template.response import TemplateResponse from django.urls import reverse @@ -11,7 +12,8 @@ from oioioi.base.menu import menu_registry from oioioi.base.permissions import enforce_condition from oioioi.contests.menu import contest_admin_menu_registry -from oioioi.contests.models import ProblemInstance, ContestPermission, contest_permissions, ContestAttachment +from oioioi.contests.models import ProblemInstance, ContestPermission, contest_permissions, ContestAttachment, \ + Submission from oioioi.contests.utils import ( can_enter_contest, contest_exists, @@ -169,14 +171,17 @@ def monitoring_view(request): attachments = ContestAttachment.objects.filter(contest_id=request.contest.id).order_by('id') for attachment in attachments: - print(attachment.pub_date, cur_time) - pub_date_relative = str(attachment.pub_date - cur_time)[:-7] if attachment.pub_date > cur_time else _("Published") + pub_date_relative = None + if attachment.pub_date: + pub_date_relative = str(attachment.pub_date - cur_time)[:-7] if attachment.pub_date > cur_time else _("Published") setattr(attachment, 'pub_date_relative', pub_date_relative) unanswered_questions = (Message.objects.filter(kind='QUESTION', message=None, contest=request.contest).count()) oldest_unanswered_question = (Message.objects.filter(kind='QUESTION', message=None, contest=request.contest) .order_by('pub_date').first()) oldest_unanswered_question_date = oldest_unanswered_question.date if oldest_unanswered_question else None + submissions_info = Submission.objects.filter(problem_instance__contest=request.contest).values('kind').annotate(total=Count('kind')).order_by() + return TemplateResponse( request, 'statistics/monitoring.html', @@ -190,5 +195,6 @@ def monitoring_view(request): 'attachments': attachments, 'unanswered_questions': unanswered_questions, 'oldest_unanswered_question': oldest_unanswered_question_date, + 'submissions_info': submissions_info }, )