feat: add due calculation

This commit is contained in:
Moritz Böhme 2025-04-06 16:55:42 +02:00
parent 4066a4f0b2
commit 956c907545

View file

@ -8,13 +8,30 @@ defmodule Putzplan.Tasks.Task do
defaults [:read, create: :*]
end
calculations do
calculate :due,
:date,
expr(
fragment(
"SELECT strftime('%F', ?)", # HACK: to cast to date
date_add(
completed_tasks.completion || today(),
repetition_days,
:day
)
)
)
end
sqlite do
table "tasks"
repo Putzplan.Repo
end
relationships do
has_many :completed_tasks, Putzplan.Tasks.CompletedTask
has_many :completed_tasks, Putzplan.Tasks.CompletedTask do
sort [:completion]
end
end
# Attributes are the simple pieces of data that exist on your resource