Strict adherence to canonical ActivityNames, to avoid the problem where Spothole was giving out activities like ["Towers", "TOWERS"]. All uses of ActivityName should now be canonical not arbitrary strings, and attempts to convert unknown strings to activitynames will be logged for me to check out.

This commit is contained in:
Ian Renton
2026-09-25 09:16:53 +01:00
parent 7417140a3d
commit 760c2412d3
17 changed files with 144 additions and 145 deletions
+7 -20
View File
@@ -6,6 +6,7 @@ from typing import ClassVar
import pytz
import requests
from core.activity_utils import get_activity_by_name
from core.constants import HTTP_HEADERS
from core.enums import ActivityName, Mode
from data.activity_ref import ActivityRef
@@ -67,16 +68,19 @@ class ParksNPeaks(HTTPSpotProvider):
# Record activity information
activity = source_spot["actClass"].upper()
found_activity = get_activity_by_name(activity)
ref_id = source_spot["actSiteID"]
if activity:
spot.add_activity(activity)
if found_activity is not None:
spot.add_activity(found_activity.name)
if ref_id:
# We can only add a reference if we know the activity it's for
if ref_id and found_activity is not None:
activity_refs = [
ActivityRef(
id=ref_id,
activity=activity,
activity=found_activity.name,
# Free text location is not present in all spots, so only add it if it's set
name=source_spot["actLocation"]
if "actLocation" in source_spot and source_spot["actLocation"] != ""
@@ -96,23 +100,6 @@ class ParksNPeaks(HTTPSpotProvider):
):
spot.comment = source_spot["actLocation"]
# Log a warning for the developer if PnP gives us an unknown programme we've never seen before
if activity not in [
ActivityName.POTA,
ActivityName.SOTA,
ActivityName.WWFF,
ActivityName.HEMA,
ActivityName.SIOTA,
ActivityName.ZLOTA,
ActivityName.KRMNPA,
ActivityName.SANPCPA,
ActivityName.LLOTA,
ActivityName.QRP,
]:
logger.warning(
f"PNP spot found with activity {activity}, developer needs to add support for this!"
)
# Add new spot to the list
new_spots.append(spot)
return new_spots