From 2a80a6530b818aa7c84a88264a76705e05579c0e Mon Sep 17 00:00:00 2001 From: fz0x1 Date: Thu, 23 Jan 2025 15:15:20 +0100 Subject: [PATCH] 20250123.1737641720 --- global/scripts/bin/diary.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/global/scripts/bin/diary.py b/global/scripts/bin/diary.py index a5ce1e0..773a3a5 100755 --- a/global/scripts/bin/diary.py +++ b/global/scripts/bin/diary.py @@ -225,13 +225,15 @@ def insert_weather(weather: dict, conn: sqlite3.Connection, metadata_id: int): def insert_location(location: dict, conn: sqlite3.Connection, metadata_id: int): cursor = conn.cursor() try: + # sometimes it can't get locality.... + locality = location["locality"] if "locality" in location else "-" cursor.execute( """ INSERT INTO location(city, lon, lat, tz, metadata_id) VALUES(?, ?, ?, ?, ?) """, [ - location["locality"], + locality, location["lon"], location["lat"], location["tzname"], @@ -324,6 +326,11 @@ def doctor(): if not location: print(f"There is no location info about {m[0]} - {m[1]}") + if not weather and not location: + # delete metadata entry if any of metadata type is not exists + print("An empty metadata was deleted") + remove_metadata(conn, m[0]) + if check_diary: dt = datetime.fromtimestamp(m[1], tz=timezone(timedelta(hours=TZ))) diary_datetime = dt.strftime("%Y/%m/%d at %I:%M:%S %p") @@ -425,7 +432,7 @@ def export(): print(f"Error writing to journal: {e.stderr}") raise - delete_entity(f"{Config.memo_url}/api/v1/{memo['name']}", headers) + # delete_entity(f"{Config.memo_url}/api/v1/{memo['name']}", headers) except Exception as e: print(f"An error occurred: {e}")