blob: 09f0ae2172d51fae2d9c4cfc7b73cd2f14ce47de (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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)
]
|