diff --git a/db/db.py b/db/db.py index 76e03fa..8871c05 100644 --- a/db/db.py +++ b/db/db.py @@ -25,7 +25,13 @@ class Database: def insert_activities(self, activities: list[Activity]): cur = self.con.cursor() + is_updated = True for act in activities: + if is_updated: + tags = cur.execute("SELECT * FROM tags WHERE id = ?", (act.tag_id, )).fetchall() + vetro_projects = cur.execute("SELECT * FROM vetro_projects WHERE id = ?", (act.vetro_project_id, )).fetchall() + if not tags or not vetro_projects: + is_updated = False try: cur.execute( "INSERT INTO activities VALUES(?,?,?,?,?,?,?,?,?)", @@ -44,6 +50,8 @@ class Database: self.con.commit() except Exception as e: logger.debug(e) + if not is_updated: + logging.info("База данных устарела. Рекомендуем обновить с помощью флага -i [--init-db]") # Доделать def insert_time_entries(self, activities: list[Activity]):