Initial content, migrated from the aml gateway rpi7-am-1
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
from i7lib.dbutils import Database
|
||||
from i7lib.timeutils import to_datetime
|
||||
|
||||
|
||||
def main():
|
||||
db = Database()
|
||||
rows = db.query(
|
||||
"oven_bar",
|
||||
filters=[
|
||||
{"column": "exited_time", "op": "eq", "value": 0},
|
||||
{"column": "deleted", "op": "eq", "value": 0},
|
||||
],
|
||||
)
|
||||
if not rows:
|
||||
print("no orphan bars to close")
|
||||
return
|
||||
|
||||
for row in rows:
|
||||
db.update("oven_bar", row["id"], {"exited_time": row["entered_time"]})
|
||||
dt = to_datetime(row["entered_time"]).strftime("%Y-%m-%d %H:%M:%S")
|
||||
print(f"closed orphan bar id={row['id']}, entered_time={dt}")
|
||||
|
||||
print(f"closed {len(rows)} orphan bar(s)")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user