From 9e5aab5b4d0cd6ee51b8c1f5d33d6ff017b4b1a0 Mon Sep 17 00:00:00 2001 From: Eduard Date: Wed, 21 May 2025 13:09:39 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D1=83=20=D0=BD=D0=B0?= =?UTF-8?q?=20=D0=BE=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5?= =?UTF-8?q?=20=D0=B1=D0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/db.py | 8 ++++++++ 1 file changed, 8 insertions(+) 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]):