diff options
author | Frederick Yin <fkfd@fkfd.me> | 2021-10-20 00:03:07 +0800 |
---|---|---|
committer | Frederick Yin <fkfd@fkfd.me> | 2021-10-20 00:03:07 +0800 |
commit | 21880c47ba381221b9a269c0aa2e83b11d8eb945 (patch) | |
tree | 33a53fb6382b5163e98584dd649e02ad7ab998b8 /jimbrella/utils.py | |
parent | eedc26ed8b2848487164614e49a4b5647d24c7d1 (diff) |
More work on web console
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) + ] |