mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2025-12-16 00:53:39 +00:00
Update API to have a sensible grouping of sig_refs rather than separate arrays of sig_refs, sig_refs_names and sig_refs_urls
This commit is contained in:
@@ -2,6 +2,7 @@ import json
|
||||
from datetime import datetime
|
||||
|
||||
from core.sig_utils import get_icon_for_sig
|
||||
from data.sig_ref import SIGRef
|
||||
from data.spot import Spot
|
||||
from spotproviders.sse_spot_provider import SSESpotProvider
|
||||
|
||||
@@ -18,17 +19,12 @@ class WWBOTA(SSESpotProvider):
|
||||
# Convert to our spot format. First we unpack references, because WWBOTA spots can have more than one for
|
||||
# n-fer activations.
|
||||
refs = []
|
||||
ref_names = []
|
||||
ref_urls = []
|
||||
for ref in source_spot["references"]:
|
||||
refs.append(ref["reference"])
|
||||
ref_names.append(ref["name"])
|
||||
# Bunkerbase URLs only work for UK bunkers, so only add a URL if we have a B/G prefix. In theory this could
|
||||
# lead to array alignment mismatches if there was e.g. a B/F bunker followed by a B/G one, we'd end up with
|
||||
# the B/G URL in index 0. But in practice there are no overlaps between B/G bunkers and any others, so an
|
||||
# activation will either be entirely B/G or not B/G at all.
|
||||
sigref = SIGRef(id=ref["reference"], name=ref["name"])
|
||||
# Bunkerbase URLs only work for UK bunkers, so only add a URL if we have a B/G prefix.
|
||||
if ref["reference"].startswith("B/G"):
|
||||
ref_urls.append("https://bunkerwiki.org/?s=" + ref["reference"])
|
||||
sigref.url="https://bunkerwiki.org/?s=" + ref["reference"]
|
||||
refs.append(sigref)
|
||||
|
||||
spot = Spot(source=self.name,
|
||||
dx_call=source_spot["call"].upper(),
|
||||
@@ -38,7 +34,6 @@ class WWBOTA(SSESpotProvider):
|
||||
comment=source_spot["comment"],
|
||||
sig="WWBOTA",
|
||||
sig_refs=refs,
|
||||
sig_refs_names=ref_names,
|
||||
icon=get_icon_for_sig("WWBOTA"),
|
||||
time=datetime.fromisoformat(source_spot["time"]).timestamp(),
|
||||
# WWBOTA spots can contain multiple references for bunkers being activated simultaneously. For
|
||||
|
||||
Reference in New Issue
Block a user