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:
@@ -17,7 +17,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class APIAlertsHandler(tornado.web.RequestHandler):
|
||||
"""API request handler for /api/v2/alerts"""
|
||||
"""API request handler for /api/v3/alerts"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
@@ -69,7 +69,7 @@ class APIAlertsHandler(tornado.web.RequestHandler):
|
||||
|
||||
|
||||
class APIAlertsStreamHandler(tornado_eventsource.handler.EventSourceHandler):
|
||||
"""API request handler for /api/v2/alerts/stream"""
|
||||
"""API request handler for /api/v3/alerts/stream"""
|
||||
|
||||
def __init__(self, application, request, **kwargs: Any):
|
||||
self._sse_alert_broadcaster = None
|
||||
@@ -169,13 +169,13 @@ def alert_allowed_by_query(alert, query):
|
||||
# the alert is a dxpedition, or contests_skip_max_duration_check and the alert is a contest, it also
|
||||
# always passes the check.
|
||||
if (
|
||||
alert.sig == ActivityName.DXPEDITION
|
||||
alert.activity == ActivityName.DXPEDITION
|
||||
and "dxpeditions_skip_max_duration_check" in query
|
||||
and query.get("dxpeditions_skip_max_duration_check").upper() == "TRUE"
|
||||
):
|
||||
continue
|
||||
if (
|
||||
alert.sig == ActivityName.CONTEST
|
||||
alert.activity == ActivityName.CONTEST
|
||||
and "contests_skip_max_duration_check" in query
|
||||
and query.get("contests_skip_max_duration_check").upper() == "TRUE"
|
||||
):
|
||||
@@ -186,14 +186,14 @@ def alert_allowed_by_query(alert, query):
|
||||
sources = query.get(k).split(",")
|
||||
if not alert.source or alert.source not in sources:
|
||||
return False
|
||||
case "sig":
|
||||
case "activity":
|
||||
# If a list of activities is provided, the alert must have an activity and it must match one of them.
|
||||
# The special activity "NO_SIG", when supplied in the list, matches alerts with no activity.
|
||||
# The special activity "NO_ACTIVITY", when supplied in the list, matches alerts with no activity.
|
||||
activities = query.get(k).split(",")
|
||||
include_no_activity = "NO_SIG" in activities
|
||||
if not alert.sig and not include_no_activity:
|
||||
include_no_activity = "NO_ACTIVITY" in activities
|
||||
if not alert.activity and not include_no_activity:
|
||||
return False
|
||||
if alert.sig and alert.sig not in activities:
|
||||
if alert.activity and alert.activity not in activities:
|
||||
return False
|
||||
case "dx_continent":
|
||||
dxconts = query.get(k).split(",")
|
||||
|
||||
Reference in New Issue
Block a user