From 1ec26a7003356e604b29eeea422b40d51d4ce700 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Wed, 15 Jul 2020 14:00:55 +0200 Subject: [PATCH] async all at once --- sdbs_infra/dashboard/views.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/sdbs_infra/dashboard/views.py b/sdbs_infra/dashboard/views.py index 2cd1bd7..619b9a1 100644 --- a/sdbs_infra/dashboard/views.py +++ b/sdbs_infra/dashboard/views.py @@ -22,13 +22,20 @@ class IndexView(TemplateView): template_name = "index.html" def get_context_data(self, **kwargs): - return { - 'links': asyncio.run(self.process_links(list(Link.objects.all()))), - 'services': asyncio.run(self.process_services(list(Service.objects.all()))), - 'machines': asyncio.run(self.process_machines(list(Machine.objects.all()))), - 'feed_items': asyncio.run(self.process_feeds(list(Feed.objects.all()))), - 'vps_stats': self.vps_stats() + 'vps_stats': self.vps_stats(), + **asyncio.run(self.process_all(list(Link.objects.all()), + list(Service.objects.all()), + list(Machine.objects.all()), + list(Feed.objects.all()))) + } + + async def process_all(self, links, services, machines, feeds): + return { + 'links': await self.process_links(links), + 'services': await self.process_services(services), + 'machines': await self.process_machines(machines), + 'feed_items': await self.process_feeds(feeds), } async def process_links(self, links):