notifications

This commit is contained in:
Egor Matveev
2022-05-15 11:05:46 +03:00
parent 138c3fa6e8
commit 4bc1981ef6
11 changed files with 205 additions and 43 deletions

View File

@@ -56,11 +56,3 @@ class MessagingSupport(BaseCommand):
channel.start_consuming()
except AMQPConnectorException:
print("connection to rabbit failed: reconnecting")
def notify(user: User, notification_type: str, text: str):
send_to_queue("notifications", {
'user_id': user.id,
'type': notification_type,
'text': text,
})

View File

@@ -5,7 +5,7 @@ from tempfile import TemporaryDirectory
from Main.models.progress import Progress
from Sprint.settings import CONSTS
from SprintLib.queue import notify, send_to_queue
from SprintLib.queue import send_to_queue
from SprintLib.utils import Timer
@@ -111,14 +111,10 @@ class BaseTester:
def notify(self):
self.solution.user.userinfo.refresh_from_db()
notify(
self.solution.user,
"solution_result",
f"Задача: {self.solution.task.name}\n"
f"Результат: {self.solution.result}\n"
f"Очки решения: {Progress.by_solution(self.solution).score}\n"
f"Текущий рейтинг: {self.solution.user.userinfo.rating}",
)
send_to_queue("notification", {
"type": "solution",
"solution_id": self.solution.id
})
def cleanup(self):
self.solution.save()