Implement a max spot age filter. Closes #18

This commit is contained in:
Ian Renton
2025-10-02 09:57:25 +01:00
parent 9640c0e0c1
commit 1a9dc0b634
8 changed files with 49 additions and 17 deletions

View File

@@ -1,12 +1,13 @@
import json
import logging
from datetime import datetime
from datetime import datetime, timedelta
from threading import Thread
import bottle
import pytz
from bottle import run, response
from core.config import MAX_SPOT_AGE
from core.constants import BANDS, ALL_MODES, MODE_TYPES, SIGS, SOURCES, CONTINENTS
from core.utils import serialize_everything
@@ -100,6 +101,10 @@ class WebServer:
case "since":
since = datetime.fromtimestamp(int(query.get(k)), pytz.UTC)
spots = [s for s in spots if s.time > since]
case "max_age":
max_age = int(query.get(k))
since = datetime.now(pytz.UTC) - timedelta(seconds=max_age)
spots = [s for s in spots if s.time > since]
case "received_since":
since = datetime.fromtimestamp(int(query.get(k)), pytz.UTC)
spots = [s for s in spots if s.received_time > since]
@@ -138,4 +143,5 @@ class WebServer:
"mode_types": MODE_TYPES,
"sigs": SIGS,
"sources": SOURCES,
"continents": CONTINENTS}
"continents": CONTINENTS,
"max_spot_age": MAX_SPOT_AGE}