From 8535e8b3ddec68de2c6c3e9d3af44b1fdd1f3379 Mon Sep 17 00:00:00 2001 From: Aaron Kable Date: Sun, 11 Aug 2024 08:33:52 +0800 Subject: [PATCH] update bridges more --- corptools/api/corporation/dashboards.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/corptools/api/corporation/dashboards.py b/corptools/api/corporation/dashboards.py index 098d5c7..56e0152 100644 --- a/corptools/api/corporation/dashboards.py +++ b/corptools/api/corporation/dashboards.py @@ -3,6 +3,7 @@ from ninja import NinjaAPI +from django.db.models import Sum from django.utils import timezone from allianceauth.services.hooks import get_extension_logger @@ -43,6 +44,16 @@ def get_dashboard_gates(request): "corporation__corporation", "system_name" ).prefetch_related('structureservice_set').filter(type_id=35841) + ozone = models.CorpAsset.objects.filter( + type_id=16273, + location_flag="StructureFuel" + ).values("location_id").annotate(total=Sum('quantity')) + levels = {} + for o in ozone: + if o["location_id"] not in levels: + levels[o["location_id"]] = 0 + levels[o["location_id"]] += o["total"] + second_systems = set() output = {} now = timezone.now() @@ -62,7 +73,7 @@ def get_dashboard_gates(request): output[to_sys]["end"] = { "system_name": s.system_name.name, "system_id": s.system_name_id, - "ozone": s.ozone_level, + "ozone": levels.get(s.structure_id), "known": True, "active": active, "expires": days, @@ -73,7 +84,7 @@ def get_dashboard_gates(request): output[from_sys]["start"] = { "system_name": s.system_name.name, "system_id": s.system_name_id, - "ozone": s.ozone_level, + "ozone": levels.get(s.structure_id), "known": True, "active": active, "expires": days,