Starting to implement queries for the JSON endpoint

This commit is contained in:
Ian Renton
2025-09-28 17:35:54 +01:00
parent bcda5769ee
commit 69e0ba0a8d
3 changed files with 16 additions and 6 deletions

View File

@@ -5,7 +5,7 @@ from providers.http_provider import HTTPProvider
# Provider for Worldwide Bunkers on the Air
# todo switch to event source API as per Steve change to Field Spotter
# todo switch to event source API as per Steve change to Field Spotter, if Python supports it
class WWBOTA(HTTPProvider):
POLL_INTERVAL_SEC = 120
SPOTS_URL = "https://api.wwbota.org/spots/"

View File

@@ -44,7 +44,7 @@ class WebServer:
def serve_api_spots(self):
self.last_api_access_time = datetime.now(pytz.UTC)
self.status = "OK"
spots_json = json.dumps(self.spot_list, default=serialize_everything)
spots_json = json.dumps(self.get_spot_list_with_filters(bottle.request.query), default=serialize_everything)
response.content_type = 'application/json'
return spots_json
@@ -66,7 +66,16 @@ class WebServer:
def serve_static_file(self, filepath):
return bottle.static_file(filepath, root="webassets")
# Utility method to apply filters to the overall spot list and return only a subset. Enables query parameters in
# the main "spots" GET call. The "query" parameter should be the result of bottle's request.query, and is a MultiDict
def get_spot_list_with_filters(self, query):
spot_subset = self.spot_list[:]
for k in query.keys():
print(k + ": " + query.get(k))
return spot_subset
# Todo spot API arguments e.g. "since" based on received_time of spots, sources, sigs, dx cont, dxcc, de cont, band, mode, filter out qrt, filter pre-qsy, sort order, list of fields
# Todo serve status API
# Todo serve Server-Sent Events to frontend - see https://medium.com/@tdenton8772/streaming-api-design-using-python-and-javascript-1b0ce8adb703
# Todo serve apidocs

View File

@@ -1,6 +1,7 @@
// TODO get all data into JS
// TODO get all data into JS on first load
// TODO subscribe to SSE to get updates, merge with local data, sort, refresh display
// TODO cap at a sensible number of lines in the table, throw away other data, make the number configurable
// TODO populate table more nicely
// TODO track last received time and use API since call, merge and sort local data, refresh display
// TODO filtering (applied locally)
// TODO look and feel