From 64979b1dd30ba1eed531b071aaf74ce1aaa1d511 Mon Sep 17 00:00:00 2001 From: Frederick Yin Date: Fri, 22 Oct 2021 23:26:49 +0800 Subject: Mark overdue umbrellas in Database --- jimbrella/routine.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'jimbrella/routine.py') diff --git a/jimbrella/routine.py b/jimbrella/routine.py index 784b60c..692807e 100644 --- a/jimbrella/routine.py +++ b/jimbrella/routine.py @@ -1,6 +1,7 @@ from .database import Database from .jform import JForm from .config import * +from .utils import local_now from .exceptions import * """A set of routine methods, run at an interval (somewhere from ten minutes to one hour), to: @@ -43,7 +44,11 @@ def sync_database(takeaway: JForm, giveback: JForm, db: Database): if sheet["jform_name"] == "takeaway": try: db.take_away( - sheet["key"], sheet["date"], sheet["name"], sheet["id"], sheet["phone"] + sheet["key"], + sheet["date"], + sheet["name"], + sheet["id"], + sheet["phone"], ) except UmbrellaStatusError: pass @@ -58,6 +63,12 @@ def sync_database(takeaway: JForm, giveback: JForm, db: Database): pass +def process_overdue(db: Database): + overdue = Database.find_overdue(db.read()) + for umb in overdue: + db.mark_overdue(umb["serial"], local_now()) + + if __name__ == "__main__": takeaway = JForm("takeaway", JFORM_TAKEAWAY_URL, JFORM_BOOKMARK_DIR) # giveback = JForm( -- cgit v1.2.3