Allow spots and alerts to have multiple activities #143

This commit is contained in:
Ian Renton
2026-09-24 22:57:46 +01:00
parent 81166dccab
commit 4477942bec
34 changed files with 217 additions and 157 deletions
+3 -3
View File
@@ -3,7 +3,7 @@ from datetime import datetime, timedelta
import pytz
from bs4 import BeautifulSoup
from core.enums import ActivityName
from core.enums import ActivityName, ActivityRefType
from data.activity_ref import ActivityRef
from data.alert import Alert
from providers.alert.http_alert_provider import HTTPAlertProvider
@@ -56,8 +56,8 @@ class BOTA(HTTPAlertProvider):
alert = Alert(
source=self.name,
dx_calls=[dx_call],
activity=ActivityName.BOTA,
activity_refs=[ActivityRef(id=ref_name, activity=ActivityName.BOTA)],
activities=[ActivityName.BOTA],
activity_refs=[ActivityRef(id=ref_name, activity=ActivityName.BOTA, ref_type=ActivityRefType.BEACH)],
start_time=date_time.timestamp(),
)
+3 -2
View File
@@ -2,7 +2,7 @@ from datetime import datetime
import pytz
from core.enums import ActivityName
from core.enums import ActivityName, ActivityRefType
from data.activity_ref import ActivityRef
from data.alert import Alert
from providers.alert.http_alert_provider import HTTPAlertProvider
@@ -38,12 +38,13 @@ class Hamsat(HTTPAlertProvider):
dx_grid=source_alert["grids"][0],
freqs_modes=freqs_modes,
comment=source_alert["comment"],
activity=ActivityName.SATELLITE,
activities=[ActivityName.SATELLITE],
# Fudge an activity ref to provide the remaining bits of data we need: the satellite and the operator's grid
activity_refs=[
ActivityRef(
activity=ActivityName.SATELLITE,
id=source_alert["satellite"]["name"],
ref_type=ActivityRefType.SATELLITE
)
],
start_time=datetime.strptime(source_alert["aos_at"], "%Y-%m-%dT%H:%M:%SZ")
+1 -1
View File
@@ -89,7 +89,7 @@ class NG3K(HTTPAlertProvider):
comment=f"{by}; {comment}; {qsl_info}",
start_time=start_timestamp,
end_time=end_timestamp,
activity=ActivityName.DXPEDITION,
activities=[ActivityName.DXPEDITION],
)
# Add to our list.
+1 -1
View File
@@ -46,7 +46,7 @@ class ParksNPeaks(HTTPAlertProvider):
dx_calls=[source_alert["CallSign"].upper()],
freqs_modes=f"{source_alert['Freq']} {source_alert['MODE']}",
comment=source_alert["Comments"],
activity=activity,
activities=[activity] if activity else [],
activity_refs=activity_refs,
start_time=start_time,
)
+3 -2
View File
@@ -2,7 +2,7 @@ from datetime import datetime
import pytz
from core.enums import ActivityName
from core.enums import ActivityName, ActivityRefType
from data.activity_ref import ActivityRef
from data.alert import Alert
from providers.alert.http_alert_provider import HTTPAlertProvider
@@ -28,11 +28,12 @@ class POTA(HTTPAlertProvider):
dx_calls=[source_alert["activator"].upper()],
freqs_modes=source_alert["frequencies"],
comment=source_alert["comments"],
activity=ActivityName.POTA,
activities=[ActivityName.POTA],
activity_refs=[
ActivityRef(
id=source_alert["reference"],
activity=ActivityName.POTA,
ref_type=ActivityRefType.PARK,
name=source_alert["name"],
url=f"https://pota.app/#/park/{source_alert['reference']}",
)
+1 -1
View File
@@ -69,7 +69,7 @@ class RSGBICALAlertProvider(ICALAlertProvider):
comment=summary,
start_time=start_timestamp,
end_time=end_timestamp,
activity=ActivityName.CONTEST,
activities=[ActivityName.CONTEST],
)
return alert
+3 -2
View File
@@ -2,7 +2,7 @@ from datetime import datetime
import pytz
from core.enums import ActivityName
from core.enums import ActivityName, ActivityRefType
from data.activity_ref import ActivityRef
from data.alert import Alert
from providers.alert.http_alert_provider import HTTPAlertProvider
@@ -34,11 +34,12 @@ class SOTA(HTTPAlertProvider):
dx_names=[source_alert["activatorName"].upper()],
freqs_modes=source_alert["frequency"],
comment=source_alert["comments"],
activity=ActivityName.SOTA,
activities=[ActivityName.SOTA],
activity_refs=[
ActivityRef(
id=f"{source_alert['associationCode']}/{source_alert['summitCode']}",
activity=ActivityName.SOTA,
ref_type=ActivityRefType.SUMMIT,
name=summit_name,
activation_score=summit_points,
)
+1 -1
View File
@@ -35,7 +35,7 @@ class WA7BNM(ICALAlertProvider):
url=url,
start_time=start_timestamp,
end_time=end_timestamp,
activity=ActivityName.CONTEST,
activities=[ActivityName.CONTEST],
)
return alert
+2 -2
View File
@@ -7,7 +7,7 @@ import pytz
from rss_parser import Parser as RSSParser
from rss_parser.models.rss import RSS
from core.enums import ActivityName
from core.enums import ActivityName, ActivityRefType
from data.activity_ref import ActivityRef
from data.alert import Alert
from providers.alert.http_alert_provider import HTTPAlertProvider
@@ -75,7 +75,7 @@ class WOTA(HTTPAlertProvider):
dx_calls=[dx_call],
freqs_modes=freqs_modes,
comment=comment,
activity_refs=[ActivityRef(id=ref, activity=ActivityName.WOTA, name=ref_name)] if ref else [],
activity_refs=[ActivityRef(id=ref, activity=ActivityName.WOTA, name=ref_name, ref_type=ActivityRefType.SUMMIT)] if ref else [],
start_time=time.timestamp(),
)
+3 -3
View File
@@ -2,7 +2,7 @@ from datetime import datetime
import pytz
from core.enums import ActivityName
from core.enums import ActivityName, ActivityRefType
from data.activity_ref import ActivityRef
from data.alert import Alert
from providers.alert.http_alert_provider import HTTPAlertProvider
@@ -28,8 +28,8 @@ class WWFF(HTTPAlertProvider):
dx_calls=[source_alert["activator_call"].upper()],
freqs_modes=f"{source_alert['band']} {source_alert['mode']}",
comment=source_alert["remarks"],
activity=ActivityName.WWFF,
activity_refs=[ActivityRef(id=source_alert["reference"], activity=ActivityName.WWFF)],
activities=[ActivityName.WWFF],
activity_refs=[ActivityRef(id=source_alert["reference"], activity=ActivityName.WWFF, ref_type=ActivityRefType.PARK)],
start_time=datetime.strptime(source_alert["utc_start"], "%Y-%m-%d %H:%M:%S")
.replace(tzinfo=pytz.UTC)
.timestamp(),
+11 -11
View File
@@ -106,49 +106,49 @@ class GMA(HTTPSpotProvider):
if "sota" in ref_info and ref_info["sota"] != "":
spot.activity_refs[0].activity = ActivityName.SOTA
spot.activity_refs[0].ref_type = ActivityRefType.SUMMIT
spot.activity = ActivityName.SOTA
spot.add_activity(ActivityName.SOTA)
else:
spot.activity_refs[0].activity = ActivityName.GMA
spot.activity_refs[0].ref_type = ActivityRefType.SUMMIT
spot.activity = ActivityName.GMA
spot.add_activity(ActivityName.GMA)
case "POTA":
spot.activity_refs[0].activity = ActivityName.POTA
spot.activity_refs[0].ref_type = ActivityRefType.PARK
spot.activity = ActivityName.POTA
spot.add_activity(ActivityName.POTA)
case "WWFF":
spot.activity_refs[0].activity = ActivityName.WWFF
spot.activity_refs[0].ref_type = ActivityRefType.PARK
spot.activity = ActivityName.WWFF
spot.add_activity(ActivityName.WWFF)
case "IOTA Island":
spot.activity_refs[0].activity = ActivityName.IOTA
spot.activity_refs[0].ref_type = ActivityRefType.ISLAND
spot.activity = ActivityName.IOTA
spot.add_activity(ActivityName.IOTA)
case "GMA Island":
spot.activity_refs[0].activity = ActivityName.GMA_ISLANDS
spot.activity_refs[0].ref_type = ActivityRefType.ISLAND
spot.activity = ActivityName.GMA_ISLANDS
spot.add_activity(ActivityName.GMA_ISLANDS)
case "Lighthouse (ILLW)":
spot.activity_refs[0].activity = ActivityName.ILLW
spot.activity_refs[0].ref_type = ActivityRefType.LIGHTHOUSE
spot.activity = ActivityName.ILLW
spot.add_activity(ActivityName.ILLW)
case "Lighthouse (ARLHS)":
spot.activity_refs[0].activity = ActivityName.ARLHS
spot.activity_refs[0].ref_type = ActivityRefType.LIGHTHOUSE
spot.activity = ActivityName.ARLHS
spot.add_activity(ActivityName.ARLHS)
case "Castle":
spot.activity_refs[0].activity = ActivityName.WCA
spot.activity_refs[0].ref_type = ActivityRefType.CASTLE
spot.activity = ActivityName.WCA
spot.add_activity(ActivityName.WCA)
case "Mill":
spot.activity_refs[0].activity = ActivityName.MOTA
spot.activity_refs[0].ref_type = ActivityRefType.MILL
spot.activity = ActivityName.MOTA
spot.add_activity(ActivityName.MOTA)
case _:
logger.warning(
f"GMA spot found with ref type {ref_info['reftype']}, developer needs to add support for this!"
)
spot.activity_refs[0].activity = ref_info["reftype"]
spot.activity = ref_info["reftype"]
spot.add_activity(ref_info["reftype"])
elif not ref_response.from_cache:
if not ref_response.ok:
+1 -1
View File
@@ -62,7 +62,7 @@ class HEMA(HTTPSpotProvider):
freq=float(freq_mode_match.group(1)) * 1000000,
mode=Mode.from_name(freq_mode_match.group(2).upper()),
comment=spotter_comment_match.group(2),
activity=ActivityName.HEMA,
activities=[ActivityName.HEMA],
activity_refs=[
ActivityRef(
id=spot_items[3].upper(),
+1 -1
View File
@@ -34,7 +34,7 @@ class LLOTA(HTTPSpotProvider):
freq=float(source_spot["frequency"]) * 1000000,
mode=Mode.from_name(source_spot["mode"].upper()),
comment=comment,
activity=ActivityName.LLOTA,
activities=[ActivityName.LLOTA],
activity_refs=[
ActivityRef(
id=source_spot["reference"],
+2 -2
View File
@@ -70,7 +70,7 @@ class ParksNPeaks(HTTPSpotProvider):
ref_id = source_spot["actSiteID"]
if activity:
spot.activity = activity
spot.add_activity(activity)
if ref_id:
activity_refs = [
@@ -130,7 +130,7 @@ class ParksNPeaks(HTTPSpotProvider):
)
ref_id = spot.activity_refs[0].id if spot.activity_refs else ""
body = {
"actClass": spot.activity or "",
"actClass": next((a for a in spot.activities if self.can_submit_spot(a)), ""),
"actCallsign": spot.dx_call,
"actSite": ref_id,
"mode": spot.mode or "",
+1 -1
View File
@@ -33,7 +33,7 @@ class POTA(HTTPSpotProvider):
freq=float(source_spot["frequency"]) * 1000 if source_spot["frequency"] != "INVALID" else None,
mode=Mode.from_name(source_spot["mode"].upper()),
comment=source_spot["comments"],
activity=ActivityName.POTA,
activities=[ActivityName.POTA],
activity_refs=[
ActivityRef(
id=source_spot["reference"],
+1 -1
View File
@@ -57,7 +57,7 @@ class SOTA(HTTPSpotProvider):
# Seen SOTA spots with no frequency!
mode=Mode.from_name(source_spot["mode"].upper()),
comment=source_spot["comments"],
activity=ActivityName.SOTA,
activities=[ActivityName.SOTA],
activity_refs=[
ActivityRef(
id=source_spot["summitCode"],
+1 -1
View File
@@ -59,7 +59,7 @@ class Tiles(HTTPSpotProvider):
freq=freq,
mode=Mode.from_name(source_spot["mode"].upper()),
comment=source_spot["notes"],
activity=ActivityName.TILES,
activities=[ActivityName.TILES],
# Tiles spots can include POTA & SOTA references, but ignore those on the basis that we will get them separately from the POTA/SOTA providers anyway.
# Just take the grid reference itself as the single Tiles activity reference.
activity_refs=[
+1 -1
View File
@@ -34,7 +34,7 @@ class Towers(HTTPSpotProvider):
dx_call=source_spot["call"].upper(),
freq=likely_freq,
comment=source_spot["comment"],
activity=ActivityName.TOWERS,
activities=[ActivityName.TOWERS],
activity_refs=[
ActivityRef(id=source_spot["ref"], activity=ActivityName.TOWERS, ref_type=ActivityRefType.TOWER)
],
+1 -1
View File
@@ -92,7 +92,7 @@ class WOTA(HTTPSpotProvider):
freq=freq_hz,
mode=Mode.from_name(mode),
comment=comment,
activity=ActivityName.WOTA,
activities=[ActivityName.WOTA],
activity_refs=(
[
ActivityRef(
+1 -1
View File
@@ -38,7 +38,7 @@ class WWBOTA(SSESpotProvider):
freq=float(source_spot["freq"]) * 1000000,
mode=Mode.from_name(source_spot["mode"].upper()) if source_spot.get("mode") else None,
comment=source_spot["comment"],
activity=ActivityName.WWBOTA,
activities=[ActivityName.WWBOTA],
activity_refs=refs,
time=datetime.fromisoformat(source_spot["time"].replace("Z", "+00:00")).timestamp(),
# WWBOTA spots can contain multiple references for bunkers being activated simultaneously. For
+1 -1
View File
@@ -30,7 +30,7 @@ class WWFF(HTTPSpotProvider):
freq=float(source_spot["frequency_khz"]) * 1000,
mode=Mode.from_name(source_spot["mode"].upper()),
comment=source_spot["remarks"],
activity=ActivityName.WWFF,
activities=[ActivityName.WWFF],
activity_refs=[
ActivityRef(
id=source_spot["reference"],
+1 -1
View File
@@ -37,7 +37,7 @@ class XOTA(WebsocketSpotProvider):
dx_call=source_spot["stationCallSign"].upper(),
freq=float(source_spot["freq"]) * 1000,
mode=Mode.from_name(source_spot["mode"].upper()),
activity=self.ACTIVITY,
activities=[self.ACTIVITY] if self.ACTIVITY else [],
activity_refs=[
ActivityRef(
id=ref_id,
+1 -1
View File
@@ -35,7 +35,7 @@ class ZLOTA(HTTPSpotProvider):
freq=freq_hz,
mode=Mode.from_name(source_spot["mode"].upper().strip()),
comment=source_spot["comments"],
activity=ActivityName.ZLOTA,
activities=[ActivityName.ZLOTA],
activity_refs=[
ActivityRef(
id=source_spot["reference"],