diff options
Diffstat (limited to 'jimbrella/utils.py')
-rw-r--r-- | jimbrella/utils.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/jimbrella/utils.py b/jimbrella/utils.py index a9f4623..09f0ae2 100644 --- a/jimbrella/utils.py +++ b/jimbrella/utils.py @@ -1,6 +1,20 @@ +from datetime import datetime, timedelta +from .config import * + + def group_by_status(umbrellas: list) -> dict: keys = set([umb["status"] for umb in umbrellas]) statuses = {} for key in keys: statuses[key] = [umb for umb in umbrellas if umb["status"] == key] return statuses + + +def find_overdue(umbrellas: list) -> list: + now = datetime.now() + return [ + umb + for umb in umbrellas + if umb["lent_at"] is not None + and now - umb["lent_at"] > timedelta(hours=DUE_HOURS) + ] |