Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create contest monitoring page #359

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
2942a79
Fix adding new tags from problem admin (#304)
Jan 10, 2024
91928e1
Merge branch 'master' of https://github.com/zggf-zggf/oioioi
Feb 28, 2024
6a07b6a
Merge branch 'master' of https://github.com/zggf-zggf/oioioi
Mar 9, 2024
f82adf0
Create monitoring site for contests
Mar 9, 2024
9e9b399
Add monitoring template
Mar 9, 2024
5d23a7e
Implement round times monitoring
Mar 9, 2024
c7bd8de
Add contest permissions info to monitoring page
Mar 10, 2024
effe9b1
Added General info tab.
SZonkil Mar 14, 2024
bf686f6
Add relative start/end times to monitoring
Mar 20, 2024
ffcfaec
Merge branch 'contest-monitoring' of https://github.com/zggf-zggf/oio…
Mar 20, 2024
215fbb3
Cleanup
Mar 20, 2024
b08adc3
Change monitoring template
Mar 20, 2024
76a41f4
Added count of unanswered questions and date of oldest unanswered que…
SZonkil Apr 3, 2024
3b7cbac
Add attachments info to monitoring page
Apr 3, 2024
5117a42
Merge branch 'contest-monitoring' of https://github.com/zggf-zggf/oio…
Apr 3, 2024
6077a74
Quickfix
Apr 3, 2024
979449f
Add submissions info to monitoring page
Apr 7, 2024
d501172
Added count of submissions with system errors
SZonkil Apr 17, 2024
71e422f
Add info about test limits to contest monitoring
Apr 17, 2024
33a5b9f
Merge branch 'contest-monitoring' of https://github.com/zggf-zggf/oio…
Apr 17, 2024
2ebbf0a
Extend problems info in monitoring page
Apr 24, 2024
a04c578
Refactor contest monitoring view
May 7, 2024
6977291
Added round extensions
SZonkil May 8, 2024
1b665d7
Added bool, that shows if someone solved a problem
SZonkil May 15, 2024
2ef9ff9
Bugfix: Changed round to round-name
SZonkil May 19, 2024
beca5c8
Bugfix: Added contest filter to SE detection
SZonkil May 22, 2024
1354ab6
Create tests_monitoring file
May 22, 2024
0741edd
Add tests round times
May 22, 2024
6f9562a
Bugfix: changed pub-date to date
SZonkil May 29, 2024
227503a
Added tests for general info
SZonkil May 29, 2024
b909df4
WIP
May 29, 2024
b1593c0
Changed fixture and fixed system error counter
SZonkil May 29, 2024
448fa8a
WIP
May 29, 2024
c540047
Merge branch 'contest-monitoring' of https://github.com/zggf-zggf/oio…
May 29, 2024
3e2f07e
WIP
May 29, 2024
36faf0e
Add attachments tests
Jun 5, 2024
29970c2
Changed fixture
SZonkil Jun 5, 2024
324c65e
Moved monitoring tests from tests_monitoring.py to tests.py
SZonkil Jun 5, 2024
3875af1
Added fixture to monitoring tests
SZonkil Jun 5, 2024
36b4f1a
Changed colspan
SZonkil Jun 5, 2024
c259d1c
Use humanize module
Jul 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions oioioi/contests/fixtures/test_contest_attachment.json

Large diffs are not rendered by default.

519 changes: 519 additions & 0 deletions oioioi/contests/fixtures/test_submission_list_with_syserr.json

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions oioioi/statistics/templates/statistics/_attachments_info.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{% load i18n pagination_tags %}
<div class="table-responsive-md">
<h4> {% trans "Attachments" %} </h4>
<table class="table table-sm table-bordered">
<thead>
<tr>
<th> {% trans "Description" %} </th>
<th> {% trans "Round" %} </th>
<th> {% trans "Publication date" %} </th>
<th> {% trans "Time left to publication" %} </th>
</tr>
</thead>
<tbody>
{% for attachment in attachments %}
<tr>
<td>{{ attachment.description }}</td>
<td>{{ attachment.round }}</td>
<td>{{ attachment.pub_date }}</td>
<td>{{ attachment.pub_date_relative }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
36 changes: 36 additions & 0 deletions oioioi/statistics/templates/statistics/_general_info.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{% load i18n pagination_tags %}
{% if rounds_times %}
<div class="table-responsive-md">
<h4> {% trans "General info" %} </h4>
<table class="table table-sm table-bordered">
<thead>
<tr>
<th> {% trans "Name" %} </th>
<th> {% trans "Value" %} </th>
</tr>
</thead>
<tbody>
<tr>
<td>Queued jobs in this contest</td>
<td>{{ q_size }}</td>
</tr>
<tr>
<td>Queued jobs on this server</td>
<td>{{ q_size_global }}</td>
</tr>
<tr>
<td>Unanswered questions</td>
<td>{{ unanswered_questions }}</td>
</tr>
<tr>
<td>Oldest unanswered question</td>
<td>{{ oldest_unanswered_question }}</td>
</tr>
<tr>
<td>Submissions with system errors</td>
<td>{{ sys_error_count }}</td>
</tr>
</tbody>
</table>
</div>
{% endif %}
20 changes: 20 additions & 0 deletions oioioi/statistics/templates/statistics/_permissions_info.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{% load i18n pagination_tags %}
<div class="table-responsive-md">
<h4> {% trans "Permissions" %} </h4>
<table class="table table-sm table-bordered">
<thead>
<tr>
<th> {% trans "Permission" %} </th>
<th> {% trans "Count" %} </th>
</tr>
</thead>
<tbody>
{% for permission, count in permissions_info.items %}
<tr>
<td>{{ permission }}</td>
<td>{{ count }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{% load i18n pagination_tags %}
{% if rounds_times %}
<div class="table-responsive-md">
<h4> {% trans "Problem and tests info" %} </h4>
{% for round, problems in tests_info.items %}
<h4>{{ round }}</h4>
{% for problem_id, problem_info in problems.items %}
<table class="table">
<thead>
<tr>
<th> Problem </th>
<th> Sumbissions limit </th>
<th> Testrun </th>
<th> Solved </th>
</tr>
</thead>
<tbody>
<tr>
<td>{{ problem_info.problem_name }}</td>
<td>{{ problem_info.submissions_limit }}</td>
<td>{% if problem_info.testrun_config %}{% trans "Enabled" %}{% else %}{% trans "Disabled" %}{% endif %}</td>
<td>{{ problem_info.solved }}
</tr>
{% if problem_info.testrun_config %}
<tr><td colspan="4"><table class="table table-sm table-bordered">
<h4>Test Run Config</h4>
<thead>
<tr>
<th> {% trans "Test run limit" %} </th>
<th> {% trans "Memory limit" %} </th>
<th> {% trans "Time limit" %} </th>
</tr>
</thead>
<tbody>
<tr>
<td>{{ problem_info.testrun_config.test_runs_limit }}</td>
<td>{{ problem_info.testrun_config.memory_limit }}</td>
<td>{{ problem_info.testrun_config.time_limit }}</td>
</tr>
</tbody>
</table></td></tr>
{% endif %}
<tr><td colspan="4"> <table class="table table-sm table-bordered">
<h4>Tests</h4>
<thead>
<tr>
<th> {% trans "Memory limit" %} </th>
<th> {% trans "Time limit" %} </th>
<th> {% trans "#tests" %} </th>
</tr>
</thead>
<tbody>
{% for t_info in problem_info.tests %}
<tr>
<td>{{ t_info.memory_limit }}</td>
<td>{{ t_info.time_limit }}</td>
<td>{{ t_info.count }}</td>
</tr>
{% endfor %}
</tbody>
</table></td> </tr>
</tbody>
</table>
{% endfor %}
{% endfor %}
</div>
{% endif %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{% load i18n pagination_tags %}
{% if rounds_times %}
<div class="table-responsive-md">
<h4> {% trans "Round time extensions" %} </h4>
<table class="table table-sm table-bordered">
<thead>
<tr>
<th> {% trans "Round" %} </th>
<th> {% trans "Extra time" %} </th>
<th> {% trans "Count" %} </th>
</tr>
</thead>
<tbody>
{% for rte in round_time_extensions%}
<tr>
<td>{{ rte.round__name }}</td>
<td>{{ rte.extra_time }}</td>
<td>{{ rte.count }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
28 changes: 28 additions & 0 deletions oioioi/statistics/templates/statistics/_rounds_info.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{% load i18n pagination_tags %}
{% if rounds_times %}
<div class="table-responsive-md">
<h4> {% trans "Rounds" %} </h4>
<table class="table table-sm table-bordered">
<thead>
<tr>
<th> {% trans "Round" %} </th>
<th> {% trans "Start time" %} </th>
<th> {% trans "Time left to start" %} </th>
<th> {% trans "End time" %} </th>
<th> {% trans "Time left to end" %} </th>
</tr>
</thead>
<tbody>
{% for round_info in rounds_times%}
<tr>
<td>{{ round_info.name }}</td>
<td>{{ round_info.start }}</td>
<td>{{ round_info.start_relative }}</td>
<td>{{ round_info.end }}</td>
<td>{{ round_info.end_relative }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
22 changes: 22 additions & 0 deletions oioioi/statistics/templates/statistics/_submissions_info.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{% load i18n pagination_tags %}
{% if rounds_times %}
<div class="table-responsive-md">
<h4> {% trans "Submission types" %} </h4>
<table class="table table-sm table-bordered">
<thead>
<tr>
<th> {% trans "Kind" %} </th>
<th> {% trans "Count" %} </th>
</tr>
</thead>
<tbody>
{% for submission_info in submissions_info %}
<tr>
<td>{{ submission_info.kind }}</td>
<td>{{ submission_info.total }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
35 changes: 35 additions & 0 deletions oioioi/statistics/templates/statistics/monitoring.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{% extends "base-with-menu.html" %}
{% load i18n pagination_tags %}

{% block title %}{% trans "Monitoring" %}{% endblock %}

{% block main-content %}
{{ head|safe }}

<div class="row">
<div class="col col-sm">
{% include "statistics/_general_info.html" %}
</div>
<div class="col col-sm">
{% include "statistics/_submissions_info.html" %}
</div>
<div class="col col-sm">
{% include "statistics/_attachments_info.html" %}
</div>
</div>
<div class="row">
<div class="col col-sm">
{% include "statistics/_permissions_info.html" %}
</div>
<div class="col col-8">
{% include "statistics/_rounds_info.html" %}
{% include "statistics/_round_time_extensions.html" %}
</div>

</div>
<div class="row">
<div class="col col-4">
{% include "statistics/_problems_and_tests_info.html" %}
</div>
</div>
{% endblock %}
69 changes: 69 additions & 0 deletions oioioi/statistics/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
submissions_histogram_contest,
test_scores,
)
from oioioi.statistics.views import get_attachments_info, get_rounds_info


class TestStatisticsPlotFunctions(TestCase):
Expand Down Expand Up @@ -214,3 +215,71 @@ def test_statistics_view(self):
},
)
self.assertContains(response, url)


class TestContestMonitoringViews(TestCase):
fixtures = [
'test_users',
'test_contest',
'test_full_package',
'test_problem_instance',
'test_submission',
'test_submission_another_user_for_statistics',
'test_extra_rounds',
'test_extra_problem',
'test_permissions',
'test_messages',
'test_second_user_messages',
'test_contest_attachment',
'test_submission_list_with_syserr',
]

def setUp(self):
self.request = RequestFactory().request()
self.request.user = User.objects.get(username='test_user')
self.request.contest = Contest.objects.get()
self.request.timestamp = datetime(2014, 8, 5, tzinfo=timezone.utc)

def test_permissions_info(self):
contest = Contest.objects.get()
url = reverse('monitoring', kwargs={'contest_id': contest.id})
self.assertTrue(self.client.login(username='test_admin'))

with fake_time(datetime(2014, 8, 5, tzinfo=timezone.utc)):
response = self.client.get(url)
self.assertRegex(str(response.content), r"Admin</td>... *<td>1")
self.assertRegex(str(response.content), r"Basic Admin</td>... *<td>1")
self.assertRegex(str(response.content), r"Observer</td>... *<td>1")
self.assertRegex(str(response.content), r"Personal Data</td>... *<td>1")
self.assertRegex(str(response.content), r"Participant</td>... *<td>0")

def test_round_info(self):
with fake_time(datetime(2015, 7, 5, tzinfo=timezone.utc)):
self.assertTrue(self.client.login(username='test_admin'))
rounds_info = get_rounds_info(self.request)
for ri in rounds_info:
if ri['name'] == 'Past round':
self.assertTrue(ri['start_relative'] == 'Started')
self.assertTrue(ri['end_relative'] == 'Finished')
if ri['name'] == 'Future round':
self.assertTrue(ri['start_relative'] == '11 months')

def test_questions_info(self):
contest = Contest.objects.get()
url = reverse('monitoring', kwargs={'contest_id': contest.id})
self.assertTrue(self.client.login(username='test_admin'))
with fake_time(datetime(2015, 8, 5, tzinfo=timezone.utc)):
response = self.client.get(url)
self.assertRegex(str(response.content), r"Unanswered questions</td>... *<td>2")
self.assertRegex(str(response.content), r"Oldest unanswered question</td>... *<td>2012-09-07 13:14:24")
self.assertRegex(str(response.content), r"Submissions with system errors</td>... *<td>2")

def test_attachments_info(self):
self.assertTrue(self.client.login(username='test_admin'))
attachments_info = get_attachments_info(self.request)
for ai in attachments_info:
if ai.description == 'published attachment':
self.assertTrue(ai.pub_date_relative == 'Published')
if ai.description == 'unpublished attachment':
self.assertTrue(ai.pub_date_relative != 'Published')

1 change: 1 addition & 0 deletions oioioi/statistics/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@
name='statistics_view_without_object',
),
re_path(r'^stat/$', views.statistics_view, name='statistics_main'),
re_path(r'^monitoring/$', views.monitoring_view, name='monitoring'),
]
Loading
Loading