mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2025-10-27 16:59:25 +00:00
Implement a max spot age filter. Closes #18
This commit is contained in:
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user