20250123.1737641720
This commit is contained in:
parent
30cff1322d
commit
2a80a6530b
1 changed files with 9 additions and 2 deletions
|
@ -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):
|
def insert_location(location: dict, conn: sqlite3.Connection, metadata_id: int):
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
try:
|
try:
|
||||||
|
# sometimes it can't get locality....
|
||||||
|
locality = location["locality"] if "locality" in location else "-"
|
||||||
cursor.execute(
|
cursor.execute(
|
||||||
"""
|
"""
|
||||||
INSERT INTO location(city, lon, lat, tz, metadata_id)
|
INSERT INTO location(city, lon, lat, tz, metadata_id)
|
||||||
VALUES(?, ?, ?, ?, ?)
|
VALUES(?, ?, ?, ?, ?)
|
||||||
""",
|
""",
|
||||||
[
|
[
|
||||||
location["locality"],
|
locality,
|
||||||
location["lon"],
|
location["lon"],
|
||||||
location["lat"],
|
location["lat"],
|
||||||
location["tzname"],
|
location["tzname"],
|
||||||
|
@ -324,6 +326,11 @@ def doctor():
|
||||||
if not location:
|
if not location:
|
||||||
print(f"There is no location info about {m[0]} - {m[1]}")
|
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:
|
if check_diary:
|
||||||
dt = datetime.fromtimestamp(m[1], tz=timezone(timedelta(hours=TZ)))
|
dt = datetime.fromtimestamp(m[1], tz=timezone(timedelta(hours=TZ)))
|
||||||
diary_datetime = dt.strftime("%Y/%m/%d at %I:%M:%S %p")
|
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}")
|
print(f"Error writing to journal: {e.stderr}")
|
||||||
raise
|
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:
|
except Exception as e:
|
||||||
print(f"An error occurred: {e}")
|
print(f"An error occurred: {e}")
|
||||||
|
|
Loading…
Add table
Reference in a new issue