mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-02-04 01:04:33 +00:00
Move activation_score into SIGRef. Closes #91
This commit is contained in:
@@ -20,13 +20,18 @@ class SOTA(HTTPAlertProvider):
|
|||||||
# Iterate through source data
|
# Iterate through source data
|
||||||
for source_alert in http_response.json():
|
for source_alert in http_response.json():
|
||||||
# Convert to our alert format
|
# 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,
|
alert = Alert(source=self.name,
|
||||||
source_id=source_alert["id"],
|
source_id=source_alert["id"],
|
||||||
dx_calls=[source_alert["activatingCallsign"].upper()],
|
dx_calls=[source_alert["activatingCallsign"].upper()],
|
||||||
dx_names=[source_alert["activatorName"].upper()],
|
dx_names=[source_alert["activatorName"].upper()],
|
||||||
freqs_modes=source_alert["frequency"],
|
freqs_modes=source_alert["frequency"],
|
||||||
comment=source_alert["comments"],
|
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"],
|
start_time=datetime.strptime(source_alert["dateActivated"],
|
||||||
"%Y-%m-%dT%H:%M:%SZ").replace(tzinfo=pytz.UTC).timestamp(),
|
"%Y-%m-%dT%H:%M:%SZ").replace(tzinfo=pytz.UTC).timestamp(),
|
||||||
is_dxpedition=False)
|
is_dxpedition=False)
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ def populate_sig_ref_info(sig_ref):
|
|||||||
sig_ref.grid = data["locator"] if "locator" in data else None
|
sig_ref.grid = data["locator"] if "locator" in data else None
|
||||||
sig_ref.latitude = data["latitude"] if "latitude" 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.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":
|
elif sig.upper() == "WWBOTA":
|
||||||
data = SEMI_STATIC_URL_DATA_CACHE.get("https://api.wwbota.org/bunkers/" + ref_id,
|
data = SEMI_STATIC_URL_DATA_CACHE.get("https://api.wwbota.org/bunkers/" + ref_id,
|
||||||
headers=HTTP_HEADERS).json()
|
headers=HTTP_HEADERS).json()
|
||||||
|
|||||||
@@ -53,8 +53,6 @@ class Alert:
|
|||||||
sig: str = None
|
sig: str = None
|
||||||
# SIG references. We allow multiple here for e.g. n-fer activations, unlike ADIF SIG_INFO
|
# SIG references. We allow multiple here for e.g. n-fer activations, unlike ADIF SIG_INFO
|
||||||
sig_refs: list = None
|
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.
|
# Whether this alert is for a DXpedition, as opposed to e.g. an xOTA programme.
|
||||||
is_dxpedition: bool = False
|
is_dxpedition: bool = False
|
||||||
# Where we got the alert from, e.g. "POTA", "SOTA"...
|
# Where we got the alert from, e.g. "POTA", "SOTA"...
|
||||||
|
|||||||
@@ -18,3 +18,5 @@ class SIGRef:
|
|||||||
longitude: float = None
|
longitude: float = None
|
||||||
# Maidenhead grid reference of the reference, if known.
|
# Maidenhead grid reference of the reference, if known.
|
||||||
grid: str = None
|
grid: str = None
|
||||||
|
# Activation score. SOTA only
|
||||||
|
activation_score: int = None
|
||||||
@@ -106,8 +106,6 @@ class Spot:
|
|||||||
sig: str = None
|
sig: str = None
|
||||||
# SIG references. We allow multiple here for e.g. n-fer activations, unlike ADIF SIG_INFO
|
# SIG references. We allow multiple here for e.g. n-fer activations, unlike ADIF SIG_INFO
|
||||||
sig_refs: list = None
|
sig_refs: list = None
|
||||||
# Activation score. SOTA only
|
|
||||||
activation_score: int = None
|
|
||||||
|
|
||||||
# Timing info
|
# Timing info
|
||||||
|
|
||||||
|
|||||||
@@ -45,9 +45,8 @@ class SOTA(HTTPSpotProvider):
|
|||||||
mode=source_spot["mode"].upper(),
|
mode=source_spot["mode"].upper(),
|
||||||
comment=source_spot["comments"],
|
comment=source_spot["comments"],
|
||||||
sig="SOTA",
|
sig="SOTA",
|
||||||
sig_refs=[SIGRef(id=source_spot["summitCode"], sig="SOTA", name=source_spot["summitName"])],
|
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(),
|
time=datetime.fromisoformat(source_spot["timeStamp"]).timestamp())
|
||||||
activation_score=source_spot["points"])
|
|
||||||
|
|
||||||
# Add to our list. Don't worry about de-duping, removing old spots etc. at this point; other code will do
|
# Add to our list. Don't worry about de-duping, removing old spots etc. at this point; other code will do
|
||||||
# that for us.
|
# that for us.
|
||||||
|
|||||||
@@ -14,7 +14,9 @@ info:
|
|||||||
|
|
||||||
### 1.1
|
### 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:
|
contact:
|
||||||
email: ian@ianrenton.com
|
email: ian@ianrenton.com
|
||||||
license:
|
license:
|
||||||
@@ -940,6 +942,10 @@ components:
|
|||||||
type: number
|
type: number
|
||||||
description: Longitude of the reference, in degrees, if known.
|
description: Longitude of the reference, in degrees, if known.
|
||||||
example: -1.2345
|
example: -1.2345
|
||||||
|
activation_score:
|
||||||
|
type: integer
|
||||||
|
description: Activation score. SOTA only
|
||||||
|
example: 0
|
||||||
|
|
||||||
Spot:
|
Spot:
|
||||||
type: object
|
type: object
|
||||||
@@ -1086,10 +1092,6 @@ components:
|
|||||||
items:
|
items:
|
||||||
$ref: '#/components/schemas/SIGRef'
|
$ref: '#/components/schemas/SIGRef'
|
||||||
description: SIG references. We allow multiple here for e.g. n-fer activations, unlike ADIF SIG_INFO
|
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:
|
qrt:
|
||||||
type: boolean
|
type: boolean
|
||||||
description: QRT state. Some APIs return spots marked as QRT. Otherwise we can check the comments.
|
description: QRT state. Some APIs return spots marked as QRT. Otherwise we can check the comments.
|
||||||
@@ -1194,10 +1196,6 @@ components:
|
|||||||
items:
|
items:
|
||||||
$ref: '#/components/schemas/SIGRef'
|
$ref: '#/components/schemas/SIGRef'
|
||||||
description: SIG references. We allow multiple here for e.g. n-fer activations, unlike ADIF SIG_INFO
|
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:
|
source:
|
||||||
type: string
|
type: string
|
||||||
description: Where we got the alert from.
|
description: Where we got the alert from.
|
||||||
|
|||||||
Reference in New Issue
Block a user