mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-09-24 16:24:32 +00:00
First attempt at converting "sig" to "activity" for v3
This commit is contained in:
@@ -16,7 +16,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class APISpotsHandler(tornado.web.RequestHandler):
|
||||
"""API request handler for /api/v2/spots"""
|
||||
"""API request handler for /api/v3/spots"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
@@ -68,7 +68,7 @@ class APISpotsHandler(tornado.web.RequestHandler):
|
||||
|
||||
|
||||
class APISpotsStreamHandler(tornado_eventsource.handler.EventSourceHandler):
|
||||
"""API request handler for /api/v2/spots/stream"""
|
||||
"""API request handler for /api/v3/spots/stream"""
|
||||
|
||||
def __init__(self, application, request, **kwargs: Any):
|
||||
self._sse_spot_broadcaster = None
|
||||
@@ -196,25 +196,25 @@ def spot_allowed_by_query(spot, query):
|
||||
sources = query.get(k).split(",")
|
||||
if not spot.source or spot.source not in sources:
|
||||
return False
|
||||
case "sig":
|
||||
case "activity":
|
||||
# If a list of activities is provided, the spot must have an activity and it must match one of them.
|
||||
# The special activity "NO_SIG", when supplied in the list, matches spots with no activity.
|
||||
# The special activity "NO_ACTIVITY", when supplied in the list, matches spots with no activity.
|
||||
activities = query.get(k).split(",")
|
||||
include_no_activity = "NO_SIG" in activities
|
||||
if not spot.sig and not include_no_activity:
|
||||
include_no_activity = "NO_ACTIVITY" in activities
|
||||
if not spot.activity and not include_no_activity:
|
||||
return False
|
||||
if spot.sig and spot.sig not in activities:
|
||||
if spot.activity and spot.activity not in activities:
|
||||
return False
|
||||
case "needs_sig":
|
||||
case "needs_activity":
|
||||
# If true, an activity is required, regardless of what it is, it just can't be missing. Mutually
|
||||
# exclusive with supplying the special "NO_SIG" parameter to the "sig" query param.
|
||||
# exclusive with supplying the special "NO_ACTIVITY" parameter to the "activity" query param.
|
||||
needs_activity = query.get(k).upper() == "TRUE"
|
||||
if needs_activity and not spot.sig:
|
||||
if needs_activity and not spot.activity:
|
||||
return False
|
||||
case "needs_sig_ref":
|
||||
case "needs_activity_ref":
|
||||
# If true, at least one activity ref is required, regardless of what it is, it just can't be missing.
|
||||
needs_activity_ref = query.get(k).upper() == "TRUE"
|
||||
if needs_activity_ref and (not spot.sig_refs or len(spot.sig_refs) == 0):
|
||||
if needs_activity_ref and (not spot.activity_refs or len(spot.activity_refs) == 0):
|
||||
return False
|
||||
case "band":
|
||||
bands = query.get(k).split(",")
|
||||
|
||||
Reference in New Issue
Block a user