Doing a lot of overhaul to add reminders
This commit is contained in:
@ -5,14 +5,15 @@ DATABASE = "nessa.db"
|
||||
|
||||
async def init_db():
|
||||
async with aiosqlite.connect(DATABASE) as db:
|
||||
await db.execute(
|
||||
'''CREATE TABLE IF NOT EXISTS projects(
|
||||
await db.execute("PRAGMA foreign_keys = ON") # Enable foreign key constraint support
|
||||
await db.execute('''
|
||||
CREATE TABLE IF NOT EXISTS projects(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
name TEXT UNIQUE,
|
||||
description TEXT)'''
|
||||
)
|
||||
await db.execute(
|
||||
'''CREATE TABLE IF NOT EXISTS tasks(
|
||||
description TEXT)
|
||||
''')
|
||||
await db.execute('''
|
||||
CREATE TABLE IF NOT EXISTS tasks(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
project_id INTEGER,
|
||||
description TEXT,
|
||||
@ -20,17 +21,16 @@ async def init_db():
|
||||
deadline TEXT,
|
||||
status TEXT,
|
||||
priority TEXT,
|
||||
notification_channel_id TEXT,
|
||||
reminder_time DATETIME,
|
||||
reminder_sent BOOLEAN DEFAULT FALSE,
|
||||
FOREIGN KEY(project_id) REFERENCES projects(id))
|
||||
'''
|
||||
)
|
||||
await db.execute(
|
||||
'''CREATE TABLE IF NOT EXISTS user_consents(
|
||||
''')
|
||||
await db.execute('''
|
||||
CREATE TABLE IF NOT EXISTS user_consents(
|
||||
user_id INTEGER PRIMARY KEY,
|
||||
consent_given BOOLEAN NOT NULL
|
||||
)'''
|
||||
)
|
||||
consent_given BOOLEAN NOT NULL)
|
||||
''')
|
||||
await db.commit()
|
||||
|
||||
async def add_project(name, description):
|
||||
@ -51,19 +51,19 @@ async def get_project_name(project_id):
|
||||
result = await cursor.fetchone()
|
||||
return result[0] if result else None
|
||||
|
||||
async def add_task_to_project(project_id, description, assignee, deadline, status, priority, reminder_time=None):
|
||||
async def add_task_to_project(project_id, description, assignee, deadline, status, priority, notification_channel_id=None, reminder_time=None):
|
||||
async with aiosqlite.connect(DATABASE) as db:
|
||||
await db.execute(
|
||||
"INSERT INTO tasks (project_id, description, assignee, deadline, status, priority, reminder_time) VALUES (?, ?, ?, ?, ?, ?, ?)",
|
||||
(project_id, description, assignee, deadline, status, priority, reminder_time)
|
||||
"INSERT INTO tasks (project_id, description, assignee, deadline, status, priority, notification_channel_id, reminder_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
(project_id, description, assignee, deadline, status, priority, notification_channel_id, reminder_time)
|
||||
)
|
||||
await db.commit()
|
||||
|
||||
async def update_task(task_id, description, assignee, deadline, status, priority, reminder_time=None):
|
||||
async def update_task(task_id, description, assignee, deadline, status, priority, notification_channel_id=None, reminder_time=None):
|
||||
async with aiosqlite.connect(DATABASE) as db:
|
||||
await db.execute(
|
||||
"UPDATE tasks SET description=?, assignee=?, deadline=?, status=?, priority=?, reminder_time=? WHERE id=?",
|
||||
(description, assignee, deadline, status, priority, reminder_time, task_id)
|
||||
"UPDATE tasks SET description=?, assignee=?, deadline=?, status=?, priority=?, notification_channel_id=?, reminder_time=? WHERE id=?",
|
||||
(description, assignee, deadline, status, priority, notification_channel_id, reminder_time, task_id)
|
||||
)
|
||||
await db.commit()
|
||||
|
||||
|
Reference in New Issue
Block a user