20250123.1737641720

This commit is contained in:
fz0x1 2025-01-23 15:15:20 +01:00
parent 30cff1322d
commit 2a80a6530b

View file

@ -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}")