loop
This commit is contained in:
parent
364dd5119c
commit
65e973c3b0
21
Main/management/commands/loop.py
Normal file
21
Main/management/commands/loop.py
Normal 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)
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user