This commit is contained in:
Egor Matveev 2022-02-26 13:19:26 +03:00
parent 364dd5119c
commit 65e973c3b0
4 changed files with 35 additions and 1 deletions

View File

@ -0,0 +1,21 @@
import datetime
from time import sleep
from django.core.management.base import BaseCommand
from django.utils import timezone
from Checker.models import Checker
class Command(BaseCommand):
help = "starts loop"
def check_checkers(self):
for checker in Checker.objects.filter(testing_solution__isnull=False, last_request__lt=timezone.now() - datetime.timedelta(seconds=3)):
checker.testing_solution.result = 'In queue'
checker.testing_solution.save()
def handle(self, *args, **options):
while True:
self.check_checkers()
sleep(5)

View File

@ -12,4 +12,7 @@ class SolutionsView(BaseView):
queries.append('task_id=' + self.request.GET['task_id'])
if 'set_id' in self.request.GET.keys():
queries.append('set_id=' + self.request.GET['set_id'])
self.context['in_set'] = True
else:
self.context['in_set'] = False
self.context['query'] = '&'.join(queries)

View File

@ -55,6 +55,15 @@ services:
depends_on:
- web
loop:
image: mathwave/sprint-repo:sprint
restart: always
environment:
HOST: $HOST
command: ./manage.py loop
depends_on:
- web
rabbitmq:
restart: always
build:
@ -101,3 +110,4 @@ services:
- bot
- postgres
- apply-languages
- loop

View File

@ -23,7 +23,7 @@
{% block onload %}doPoll(){% endblock %}
{% block main %}
<h2>Решения</h2>
<h2>Решения <a href="{% if in_set %}/set?set_id={{ set.id }}{% else %}/task?task_id={{ task.id }}{% endif %}">{% if in_set %}{{ set.name }}{% else %}{{ task.name }}{% endif %}</a></h2>
<!--
<h4>Фильтр (пока недоступная опция)</h4>
<div>