feat: support updating notes and reminders
All checks were successful
quality / test (3.10) (push) Successful in 10m42s
quality / test (3.12) (push) Successful in 9m25s

This commit is contained in:
kandrusyak
2026-07-27 19:53:08 +03:00
parent d1c1ef68d3
commit 7dc5a1f7f2
4 changed files with 418 additions and 3 deletions

View File

@@ -321,6 +321,18 @@ class AssistantStorage:
).fetchall()
return [row_to_dict(row) for row in rows]
def update_note(self, user_id: int, note_id: int, text: str) -> bool:
with self._connection() as connection:
cursor = connection.execute(
"""
UPDATE notes
SET text = ?
WHERE user_id = ? AND id = ?
""",
(text, user_id, note_id),
)
return cursor.rowcount > 0
def delete_note(self, user_id: int, note_id: int) -> bool:
with self._connection() as connection:
cursor = connection.execute(
@@ -366,6 +378,35 @@ class AssistantStorage:
).fetchall()
return [row_to_dict(row) for row in rows]
def update_reminder(
self,
user_id: int,
reminder_id: int,
*,
text: str | None = None,
remind_at_utc: datetime | None = None,
) -> bool:
with self._connection() as connection:
cursor = connection.execute(
"""
UPDATE reminders
SET text = COALESCE(?, text),
remind_at = COALESCE(?, remind_at)
WHERE user_id = ? AND id = ? AND status = 'pending'
""",
(
text,
(
to_utc_iso(remind_at_utc)
if remind_at_utc is not None
else None
),
user_id,
reminder_id,
),
)
return cursor.rowcount > 0
def cancel_reminder(self, user_id: int, reminder_id: int) -> bool:
with self._connection() as connection:
cursor = connection.execute(