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

@@ -38,7 +38,7 @@ class BOTA(HTTPAlertProvider):
# Convert to our alert format
alert = Alert(source=self.name,
dx_calls=[dx_call],
sig_refs=[SIGRef(id=ref_name, sig="BOTA", name=ref_name, url="https://www.beachesontheair.com/beaches/" + ref_name.lower().replace(" ", "-"))],
sig_refs=[SIGRef(id=ref_name, sig="BOTA")],
start_time=date_time.timestamp(),
is_dxpedition=False)

View File

@@ -22,6 +22,7 @@ class ParksNPeaks(HTTPAlertProvider):
# Iterate through source data
for source_alert in http_response.json():
# Calculate some things
sig = source_alert["Class"]
if " - " in source_alert["Location"]:
split = source_alert["Location"].split(" - ")
sig_ref = split[0]
@@ -38,17 +39,17 @@ class ParksNPeaks(HTTPAlertProvider):
dx_calls=[source_alert["CallSign"].upper()],
freqs_modes=source_alert["Freq"] + " " + source_alert["MODE"],
comment=source_alert["Comments"],
sig_refs=[SIGRef(id=sig_ref, sig=source_alert["Class"], name=sig_ref_name)],
sig_refs=[SIGRef(id=sig_ref, sig=sig, name=sig_ref_name)],
start_time=start_time,
is_dxpedition=False)
# Log a warning for the developer if PnP gives us an unknown programme we've never seen before
if alert.sig not in ["POTA", "SOTA", "WWFF", "SiOTA", "ZLOTA", "KRMNPA"]:
logging.warn("PNP alert found with sig " + alert.sig + ", developer needs to add support for this!")
if sig and sig not in ["POTA", "SOTA", "WWFF", "SiOTA", "ZLOTA", "KRMNPA"]:
logging.warn("PNP alert found with sig " + sig + ", developer needs to add support for this!")
# If this is POTA, SOTA or WWFF data we already have it through other means, so ignore. Otherwise, add to
# the alert list. Note that while ZLOTA has its own spots API, it doesn't have its own alerts API. So that
# means the PnP *spot* provider rejects ZLOTA spots here, but the PnP *alerts* provider here allows ZLOTA.
if alert.sig not in ["POTA", "SOTA", "WWFF"]:
if sig not in ["POTA", "SOTA", "WWFF"]:
new_alerts.append(alert)
return new_alerts

View File

@@ -67,7 +67,6 @@ def get_sig_ref_info(sig, sig_ref_id):
sig_ref.latitude = data["latitude"] if "latitude" in data else None
sig_ref.longitude = data["longitude"] if "longitude" in data else None
elif sig.upper() == "WWFF":
sig_ref.url = "https://wwff.co/directory/?showRef=" + sig_ref_id
elif sig.upper() == "SIOTA":
siota_csv_data = SEMI_STATIC_URL_DATA_CACHE.get("https://www.silosontheair.com/data/silos.csv",
@@ -100,6 +99,10 @@ def get_sig_ref_info(sig, sig_ref_id):
sig_ref.grid = latlong_to_locator(asset["y"], asset["x"], 6)
sig_ref.latitude = asset["y"]
sig_ref.longitude = asset["x"]
elif sig.upper() == "BOTA":
if not sig_ref.name:
sig_ref.name = sig_ref.id
sig_ref.url = "https://www.beachesontheair.com/beaches/" + sig_ref.name.lower().replace(" ", "-")
elif sig.upper() == "WAB" or sig.upper() == "WAI":
ll = wab_wai_square_to_lat_lon(sig_ref_id)
if ll:

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: