feat: allow deleting VK schedules

This commit is contained in:
nyan404 committed 2026-09-06 18:29:14 +03:00
1 parent 84e37c7ee7
commit c64ec6a2bf
3 files changed
+24 -2

No files matched your search

+9
View File
@@ -147,6 +147,15 @@ class VkConversationStore:
keys = ("id","template_id","peer_id","times","weekdays","timezone","active","starts_on","ends_on")
return [{**dict(zip(keys, row[:3] + (json.loads(row[3]), json.loads(row[4])) + row[5:]))} for row in rows]
def delete_schedule(self, schedule_id: int) -> bool:
"""Delete one schedule and its no-longer-relevant delivery claims."""
rows = self._execute("SELECT id FROM vk_schedules WHERE id=?", (schedule_id,), fetch=True) or []
if not rows:
return False
self._execute("DELETE FROM vk_delivery_attempts WHERE schedule_id=?", (schedule_id,))
self._execute("DELETE FROM vk_schedules WHERE id=?", (schedule_id,))
return True
def claim_delivery(self, schedule_id: int, planned_for: str) -> bool:
try:
self._execute("INSERT INTO vk_delivery_attempts(schedule_id,planned_for) VALUES(?,?)", (schedule_id, planned_for))