diff --git a/db.sqlite3 b/db.sqlite3
new file mode 100644
index 0000000..20fc4fb
Binary files /dev/null and b/db.sqlite3 differ
diff --git a/waiting_room/tasks.py b/waiting_room/tasks.py
index 31411b8..a7ccaa3 100644
--- a/waiting_room/tasks.py
+++ b/waiting_room/tasks.py
@@ -1,5 +1,6 @@
from huey.contrib.djhuey import task
import operator
+from django.template.loader import render_to_string
from itertools import permutations
from collections import Counter
from functools import reduce
@@ -7,13 +8,16 @@ from math import factorial
from channels.layers import get_channel_layer
from asgiref.sync import async_to_sync
-def render_progress_bar(group_name, message):
+def render_progress_bar(group_name, progress, result=None):
channel_layer = get_channel_layer()
async_to_sync(channel_layer.group_send)(
group_name,
{
'type': 'channel_message',
- 'message': f'
{message}
',
+ 'message': render_to_string('components/tasks/update.html', {
+ 'progress': progress,
+ 'result': result,
+ }),
}
)
@@ -64,7 +68,7 @@ def calculate_min_distance(group_name):
route_distance += distances[perm[-1]][perm[0]] # Back to the start city
shortest_route = min(shortest_route, route_distance)
- render_progress_bar(group_name, 100)
+ render_progress_bar(group_name, 100, shortest_route)
return shortest_route
return calculate_shortest_route(distances)
diff --git a/waiting_room/templates/base.html b/waiting_room/templates/base.html
index adf3b37..61d5b04 100644
--- a/waiting_room/templates/base.html
+++ b/waiting_room/templates/base.html
@@ -6,11 +6,16 @@
{% block title %}Waiting Room{% endblock %}
+
- {% include 'progress_bar.html' %}
- {% block content %}{% endblock %}
+ {% include 'components/tasks/layout.html' %}
+ {% block content %}{% endblock %}