add goal changing to refresh_milestones()

This commit is contained in:
Lili (Tlapka) 2023-03-26 12:22:54 +02:00
parent ea1fc6e051
commit 3858a14f1a
1 changed files with 8 additions and 1 deletions

View File

@ -108,11 +108,18 @@ def refresh_milestones():
"SELECT goal FROM milestones WHERE name = ?",
(redeem,)
)
if cursor.fetchone() is None:
result = cursor.fetchone()
if result is None:
cursor.execute(
"INSERT INTO milestones(name, progress, goal, complete) VALUES(?, 0, ?, FALSE)",
(redeem, redeem_info['goal'])
)
# update existing milestone to new goal
elif result != redeem_info["goal"]:
cursor.execute(
"UPDATE milestones SET goal = ? WHERE name = ?",
(redeem_info["goal"], redeem)
)
db.commit()
except sqlite3.Error as e:
print("Failed inserting milestones to db:", e.args[0])