summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--waterspout_radar/_storage.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/waterspout_radar/_storage.py b/waterspout_radar/_storage.py
index aa9f0b1..97d16fd 100644
--- a/waterspout_radar/_storage.py
+++ b/waterspout_radar/_storage.py
@@ -13,7 +13,14 @@ class Storage:
self.db = tinydb.TinyDB(pathname, create_dirs=True)
def show(self, period: Period=None):
- return map(_radar.Prediction.from_json, self.db.all())
+ if not period:
+ now = datetime.datetime.now()
+ period = (now, now + datetime.timedelta(days=5))
+
+ def _is_between(prediction):
+ return period[0] < prediction.time and period[1] > prediction.time
+
+ return filter(_is_between, map(_radar.Prediction.from_json, self.db.all()))
def extend(self, predictions: typing.Iterable[_radar.Prediction]):
for prediction in predictions: