mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-09-25 08:44:33 +00:00
sig->activity and multiple activity changes for API v3. #143
This commit is contained in:
@@ -27,7 +27,7 @@ def get_activity_ref_info(activity_name, ref_id):
|
||||
ref_id = ref_id.replace(" ", "-")
|
||||
|
||||
# Prepare the object to be returned
|
||||
activity_ref = ActivityRef(sig=activity_name, id=ref_id)
|
||||
activity_ref = ActivityRef(activity=activity_name, id=ref_id)
|
||||
|
||||
# We can always get the reference type and the icon from the activity itself
|
||||
activity = get_activity_by_name(activity_name)
|
||||
@@ -141,11 +141,11 @@ def get_activity_ref_info(activity_name, ref_id):
|
||||
|
||||
def populate_missing_activity_ref_info(activity_ref):
|
||||
"""Look up details of an activity reference (e.g. POTA park) such as name, lat/lon, and grid. Takes in an
|
||||
activity_ref object which must at minimum have a "sig" and an "id". The rest of the object will be populated
|
||||
activity_ref object which must at minimum have an "activity" and an "id". The rest of the object will be populated
|
||||
and returned. Any data currently in the object will be kept, only missing data in the object will be populated
|
||||
if it can be determined."""
|
||||
|
||||
lookup_data = get_activity_ref_info(activity_ref.sig, activity_ref.id)
|
||||
lookup_data = get_activity_ref_info(activity_ref.activity, activity_ref.id)
|
||||
|
||||
if lookup_data:
|
||||
# Copy new activity ref data into existing object where data was previously missing
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ from core.config import SERVER_OWNER_CALLSIGN
|
||||
from data.band import Band
|
||||
|
||||
# General software
|
||||
SOFTWARE_VERSION = "2.2"
|
||||
SOFTWARE_VERSION = "3.0-pre"
|
||||
|
||||
# HTTP headers used for spot providers that use HTTP
|
||||
HTTP_HEADERS = {"User-Agent": f"Spothole v{SOFTWARE_VERSION} (operated by {SERVER_OWNER_CALLSIGN})"}
|
||||
|
||||
@@ -15,7 +15,7 @@ class DataProviders:
|
||||
self.alert_providers = []
|
||||
self.solar_condition_providers = []
|
||||
self.static_data_providers = []
|
||||
self.sig_ref_data_providers = []
|
||||
self.activity_ref_data_providers = []
|
||||
self.callsign_data_providers = []
|
||||
self._startup_timers = []
|
||||
|
||||
@@ -28,8 +28,8 @@ class DataProviders:
|
||||
self.solar_condition_providers.append(create_provider_from_config("providers.solarconditions", entry))
|
||||
for entry in config.get("static_data_providers", []):
|
||||
self.static_data_providers.append(create_provider_from_config("providers.staticdata", entry))
|
||||
for entry in config.get("sig_ref_data_providers", []):
|
||||
self.sig_ref_data_providers.append(create_provider_from_config("providers.activityrefdata", entry))
|
||||
for entry in config.get("activity_ref_data_providers", []):
|
||||
self.activity_ref_data_providers.append(create_provider_from_config("providers.activityrefdata", entry))
|
||||
for entry in config.get("callsign_data_providers", []):
|
||||
self.callsign_data_providers.append(create_provider_from_config("providers.callsigndata", entry))
|
||||
|
||||
@@ -54,7 +54,7 @@ class DataProviders:
|
||||
25.0,
|
||||
lambda: self.start_providers(self.solar_condition_providers, "solar condition"),
|
||||
),
|
||||
threading.Timer(30.0, lambda: self.start_providers(self.sig_ref_data_providers, "activity ref data")),
|
||||
threading.Timer(30.0, lambda: self.start_providers(self.activity_ref_data_providers, "activity ref data")),
|
||||
]
|
||||
for t in self._startup_timers:
|
||||
t.daemon = True
|
||||
@@ -72,7 +72,7 @@ class DataProviders:
|
||||
self.spot_providers
|
||||
+ self.alert_providers
|
||||
+ self.solar_condition_providers
|
||||
+ self.sig_ref_data_providers
|
||||
+ self.activity_ref_data_providers
|
||||
+ self.static_data_providers
|
||||
+ self.callsign_data_providers
|
||||
)
|
||||
|
||||
+1
-1
@@ -77,7 +77,7 @@ class LocationSourceForSpot(str, Enum):
|
||||
"""Where the location data came from in a spot."""
|
||||
|
||||
SPOT = "SPOT"
|
||||
SIG_REF_LOOKUP = "SIG REF LOOKUP"
|
||||
ACTIVITY_REF_LOOKUP = "ACTIVITY REF LOOKUP"
|
||||
GRID = "GRID"
|
||||
HOME_QTH = "HOME QTH"
|
||||
DXCC = "DXCC"
|
||||
|
||||
@@ -111,9 +111,9 @@ class StatusReporter:
|
||||
}
|
||||
for p in DATA_PROVIDERS.static_data_providers
|
||||
]
|
||||
DATA_STORE.status.get()["sig_ref_data_providers"] = [
|
||||
DATA_STORE.status.get()["activity_ref_data_providers"] = [
|
||||
{
|
||||
"sig_name": p.sig_name,
|
||||
"activity_name": p.activity_name,
|
||||
"enabled": p.enabled,
|
||||
"status": p.status,
|
||||
"last_updated": p.last_update_time.replace(tzinfo=pytz.UTC).timestamp()
|
||||
@@ -121,7 +121,7 @@ class StatusReporter:
|
||||
else 0,
|
||||
"reference_count": p.reference_count,
|
||||
}
|
||||
for p in DATA_PROVIDERS.sig_ref_data_providers
|
||||
for p in DATA_PROVIDERS.activity_ref_data_providers
|
||||
]
|
||||
DATA_STORE.status.get()["callsign_data_providers"] = [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user