Новая таблица tasks

This commit is contained in:
2025-06-20 16:47:05 +03:00
parent 0db2b55d9f
commit a5f86563fa
5 changed files with 105 additions and 6 deletions

View File

@@ -43,7 +43,7 @@ class Database:
is_updated = bool(tags)
try:
self.cursor.execute(
"INSERT INTO activity VALUES(?,?,?,?,?,?,?,?,?,?)",
"INSERT INTO activity VALUES(?,?,?,?,?,?,?,?,?,?,?)",
(
act.id,
act.description,
@@ -54,13 +54,14 @@ class Database:
act.is_tracked,
act.vetro_project_id,
act.tag_id,
act.task_id,
act.project_id,
)
)
except sq.IntegrityError:
self.cursor.execute(
"""UPDATE activity
SET description = ?, time_spent = ?, date_start = ?, date_end = ?, is_tracked = ?, vetro_project_id = ?, tag_id = ?, project_id = ?
SET description = ?, time_spent = ?, date_start = ?, date_end = ?, is_tracked = ?, vetro_project_id = ?, tag_id = ?, task_id = ?, project_id = ?
WHERE id = ?""",
(
act.description,
@@ -70,6 +71,7 @@ class Database:
act.is_tracked,
act.vetro_project_id,
act.tag_id,
act.task_id,
act.project_id,
act.id,
)
@@ -211,3 +213,46 @@ class Database:
]
except Exception as e:
logging.error(e)
def insert_tasks(self, tasks: list[dict]):
"""Сохраняет в БД Задачи из Redmine"""
for task in tasks:
try:
self.cursor.execute("""
INSERT INTO task(
"id",
"subject",
"description",
"status",
"priority",
"author",
"tracker",
"project"
)
VALUES(?, ?, ?, ?, ?, ?, ?, ?)""",
[v for k, v in task.items()])
except sq.IntegrityError:
self.cursor.execute("""
UPDATE task
SET "subject" = ?,
"description" = ?,
"status" = ?,
"priority" = ?,
"author" = ?,
"tracker" = ?,
"project" = ?
WHERE "id" = ?""",
(
task["subject"],
task["description"],
task["status"],
task["priority"],
task["author"],
task["tracker"],
task["project"],
task["id"]
)
)
finally:
self.con.commit()