mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-09-20 14:27:42 +00:00
Refactor activity names to use an enum instead of a string to avoid typos #147
This commit is contained in:
@@ -3,6 +3,7 @@ from datetime import datetime
|
||||
|
||||
import pytz
|
||||
|
||||
from core.enums import ActivityName
|
||||
from data.activity_ref import ActivityRef
|
||||
from data.alert import Alert
|
||||
from providers.alert.http_alert_provider import HTTPAlertProvider
|
||||
@@ -39,7 +40,7 @@ class ParksNPeaks(HTTPAlertProvider):
|
||||
activity_refs = []
|
||||
# PnP can give us an alert of class "QRP" which is the only one that's not a real activity in Spothole's
|
||||
# list, so mask this out if we got it.
|
||||
if activity != "QRP":
|
||||
if activity != ActivityName.QRP:
|
||||
activity_refs = [ActivityRef(id=ref_id, sig=activity, name=ref_name)]
|
||||
|
||||
# Convert to our alert format
|
||||
@@ -56,22 +57,22 @@ class ParksNPeaks(HTTPAlertProvider):
|
||||
|
||||
# Log a warning for the developer if PnP gives us an unknown programme we've never seen before
|
||||
if activity and activity not in [
|
||||
"POTA",
|
||||
"SOTA",
|
||||
"WWFF",
|
||||
"HEMA",
|
||||
"SIOTA",
|
||||
"ZLOTA",
|
||||
"KRMNPA",
|
||||
"SANPCPA",
|
||||
"LLOTA",
|
||||
"QRP",
|
||||
ActivityName.POTA,
|
||||
ActivityName.SOTA,
|
||||
ActivityName.WWFF,
|
||||
ActivityName.HEMA,
|
||||
ActivityName.SIOTA,
|
||||
ActivityName.ZLOTA,
|
||||
ActivityName.KRMNPA,
|
||||
ActivityName.SANPCPA,
|
||||
ActivityName.LLOTA,
|
||||
ActivityName.QRP,
|
||||
]:
|
||||
logger.warning(f"PNP alert found with activity {activity}, 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 activity not in ["POTA", "SOTA", "WWFF"]:
|
||||
if activity not in [ActivityName.POTA, ActivityName.SOTA, ActivityName.WWFF]:
|
||||
new_alerts.append(alert)
|
||||
return new_alerts
|
||||
|
||||
Reference in New Issue
Block a user