Skip to content

Commit

Permalink
add basic recurrence functionality like v2 (closes #204)
Browse files Browse the repository at this point in the history
  • Loading branch information
kraanzu committed Nov 13, 2024
1 parent 592b3e3 commit f6b8d07
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions dooit/api/hooks/update_hooks.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from datetime import datetime
from sqlalchemy import event, update
from ..todo import Todo

Expand Down Expand Up @@ -56,3 +57,18 @@ def update_parent_completed(todo: Todo):
)

connection.execute(query)


@event.listens_for(Todo, "before_update")
def update_due_for_recurrence(mapper, connection, todo: Todo):
if todo.recurrence is None:
return

if todo.due is None:
todo.due = datetime.now()

if todo.pending:
return

todo.pending = True
todo.due += todo.recurrence

0 comments on commit f6b8d07

Please sign in to comment.