Добавил новый датакласс для Деятельности трудочасов и настроил их динамическую подгрузку из Redmine
This commit is contained in:
12
db/db.py
12
db/db.py
@@ -1,8 +1,8 @@
|
||||
import logging
|
||||
import sqlite3 as sq
|
||||
|
||||
from classes import Activity, Tag
|
||||
from enums import ActivityType
|
||||
from classes import Activity, ActivityType, Tag
|
||||
from enums import ActivityType as ActivityTypeEnum
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -60,7 +60,7 @@ class Database:
|
||||
act.id,
|
||||
act.time_spent,
|
||||
act.task_id,
|
||||
ActivityType.DEVELOPMENT
|
||||
ActivityTypeEnum.DEVELOPMENT
|
||||
)
|
||||
)
|
||||
self.con.commit()
|
||||
@@ -93,11 +93,11 @@ class Database:
|
||||
except Exception as e:
|
||||
logger.debug(e)
|
||||
|
||||
def insert_activity_types(self, activity_types: dict):
|
||||
def insert_activity_types(self, activity_types: list[ActivityType]):
|
||||
cur = self.con.cursor()
|
||||
for k,v in activity_types.items():
|
||||
for activity_type in activity_types:
|
||||
try:
|
||||
cur.execute("INSERT INTO activity_types VALUES(?, ?)", (k, v))
|
||||
cur.execute("INSERT INTO activity_types VALUES(?, ?)", (activity_type.id, activity_type.title))
|
||||
self.con.commit()
|
||||
except Exception as e:
|
||||
logger.debug(e)
|
||||
|
||||
Reference in New Issue
Block a user