diff --git a/alertproviders/sota.py b/alertproviders/sota.py index 0792f3e..40371dc 100644 --- a/alertproviders/sota.py +++ b/alertproviders/sota.py @@ -20,13 +20,18 @@ class SOTA(HTTPAlertProvider): # Iterate through source data for source_alert in http_response.json(): # Convert to our alert format + details = source_alert["summitDetails"].split(", ") + summit_name = details[0] + summit_points = None + if len(details) > 2: + summit_points = int(details[-1].split(" ")[0]) alert = Alert(source=self.name, source_id=source_alert["id"], dx_calls=[source_alert["activatingCallsign"].upper()], dx_names=[source_alert["activatorName"].upper()], freqs_modes=source_alert["frequency"], comment=source_alert["comments"], - sig_refs=[SIGRef(id=source_alert["associationCode"] + "/" + source_alert["summitCode"], sig="SOTA", name=source_alert["summitDetails"])], + sig_refs=[SIGRef(id=source_alert["associationCode"] + "/" + source_alert["summitCode"], sig="SOTA", name=summit_name, activation_score=summit_points)], start_time=datetime.strptime(source_alert["dateActivated"], "%Y-%m-%dT%H:%M:%SZ").replace(tzinfo=pytz.UTC).timestamp(), is_dxpedition=False) diff --git a/core/sig_utils.py b/core/sig_utils.py index 7afc8fc..d712741 100644 --- a/core/sig_utils.py +++ b/core/sig_utils.py @@ -46,6 +46,7 @@ def populate_sig_ref_info(sig_ref): sig_ref.grid = data["locator"] if "locator" in data else None sig_ref.latitude = data["latitude"] if "latitude" in data else None sig_ref.longitude = data["longitude"] if "longitude" in data else None + sig_ref.activation_score = data["points"] if "points" in data else None elif sig.upper() == "WWBOTA": data = SEMI_STATIC_URL_DATA_CACHE.get("https://api.wwbota.org/bunkers/" + ref_id, headers=HTTP_HEADERS).json() diff --git a/data/alert.py b/data/alert.py index 508057e..4c9cba7 100644 --- a/data/alert.py +++ b/data/alert.py @@ -53,8 +53,6 @@ class Alert: sig: str = None # SIG references. We allow multiple here for e.g. n-fer activations, unlike ADIF SIG_INFO sig_refs: list = None - # Activation score. SOTA only - activation_score: int = None # Whether this alert is for a DXpedition, as opposed to e.g. an xOTA programme. is_dxpedition: bool = False # Where we got the alert from, e.g. "POTA", "SOTA"... diff --git a/data/sig_ref.py b/data/sig_ref.py index b0e78b2..76fa0b7 100644 --- a/data/sig_ref.py +++ b/data/sig_ref.py @@ -17,4 +17,6 @@ class SIGRef: # Longitude of the reference, if known. longitude: float = None # Maidenhead grid reference of the reference, if known. - grid: str = None \ No newline at end of file + grid: str = None + # Activation score. SOTA only + activation_score: int = None \ No newline at end of file diff --git a/data/spot.py b/data/spot.py index fa6da6a..21e696d 100644 --- a/data/spot.py +++ b/data/spot.py @@ -106,8 +106,6 @@ class Spot: sig: str = None # SIG references. We allow multiple here for e.g. n-fer activations, unlike ADIF SIG_INFO sig_refs: list = None - # Activation score. SOTA only - activation_score: int = None # Timing info diff --git a/spotproviders/sota.py b/spotproviders/sota.py index a858c1f..f07a779 100644 --- a/spotproviders/sota.py +++ b/spotproviders/sota.py @@ -45,9 +45,8 @@ class SOTA(HTTPSpotProvider): mode=source_spot["mode"].upper(), comment=source_spot["comments"], sig="SOTA", - sig_refs=[SIGRef(id=source_spot["summitCode"], sig="SOTA", name=source_spot["summitName"])], - time=datetime.fromisoformat(source_spot["timeStamp"]).timestamp(), - activation_score=source_spot["points"]) + sig_refs=[SIGRef(id=source_spot["summitCode"], sig="SOTA", name=source_spot["summitName"], activation_score=source_spot["points"])], + time=datetime.fromisoformat(source_spot["timeStamp"]).timestamp()) # Add to our list. Don't worry about de-duping, removing old spots etc. at this point; other code will do # that for us. diff --git a/webassets/apidocs/openapi.yml b/webassets/apidocs/openapi.yml index a9bf7ad..3e0771b 100644 --- a/webassets/apidocs/openapi.yml +++ b/webassets/apidocs/openapi.yml @@ -14,7 +14,9 @@ info: ### 1.1 - Added Server-Sent Event API endpoint. Removed band colour and icon information from spots. + * Added Server-Sent Event API endpoints for spots and alerts. + * Removed band colour and icon information from spots. + * Moved activation_score from top-level in Spot and Alert to be part of the SIGRef contact: email: ian@ianrenton.com license: @@ -940,6 +942,10 @@ components: type: number description: Longitude of the reference, in degrees, if known. example: -1.2345 + activation_score: + type: integer + description: Activation score. SOTA only + example: 0 Spot: type: object @@ -1086,10 +1092,6 @@ components: items: $ref: '#/components/schemas/SIGRef' description: SIG references. We allow multiple here for e.g. n-fer activations, unlike ADIF SIG_INFO - activation_score: - type: integer - description: Activation score. SOTA only - example: 0 qrt: type: boolean description: QRT state. Some APIs return spots marked as QRT. Otherwise we can check the comments. @@ -1194,10 +1196,6 @@ components: items: $ref: '#/components/schemas/SIGRef' description: SIG references. We allow multiple here for e.g. n-fer activations, unlike ADIF SIG_INFO - activation_score: - type: integer - description: Activation score. SOTA only - example: 0 source: type: string description: Where we got the alert from.