Tidy up some issues with alerts #74

This commit is contained in:
Ian Renton
2025-11-02 17:54:34 +00:00
parent b8e1506846
commit e83ddead62
4 changed files with 21 additions and 8 deletions

View File

@@ -1,7 +1,6 @@
import copy
import hashlib
import json
import re
from dataclasses import dataclass
from datetime import datetime, timedelta
@@ -9,7 +8,7 @@ import pytz
from core.constants import DXCC_FLAGS
from core.lookup_helper import lookup_helper
from core.sig_utils import get_icon_for_sig
from core.sig_utils import get_icon_for_sig, get_sig_ref_info
# Data class that defines an alert.
@@ -99,6 +98,16 @@ class Alert:
if self.dx_dxcc_id and self.dx_dxcc_id in DXCC_FLAGS and not self.dx_flag:
self.dx_flag = DXCC_FLAGS[self.dx_dxcc_id]
# Fetch SIG data. In case a particular API doesn't provide a full set of name, lat, lon & grid for a reference
# in its initial call, we use this code to populate the rest of the data. This includes working out grid refs
# from WAB and WAI, which count as a SIG even though there's no real lookup, just maths
if self.sig_refs and len(self.sig_refs) > 0:
for sig_ref in self.sig_refs:
lookup_data = get_sig_ref_info(sig_ref.sig, sig_ref.id)
if lookup_data:
# Update the sig_ref data from the lookup
sig_ref.__dict__.update(lookup_data.__dict__)
# If the spot itself doesn't have a SIG yet, but we have at least one SIG reference, take that reference's SIG
# and apply it to the whole spot.
if self.sig_refs and len(self.sig_refs) > 0 and not self.sig: