Task Filtering and Date Logic
Explains server-side smart filtering for tasks — how dueDate, scheduledDate, showInListFrom, and withOverdue interact to determine task visibility.
This document describes how tasks are filtered by date on the server (smart filtering) and the meaning of each date field.
Parameters for smart filtering
The main parameters for smart filtering are:
- startDate and endDate: Define the date range for the filter (e.g. today, this week).
- withOverdue (optional): When
true, overdue scheduled tasks are included; whenfalse, they are hidden. - includeUndated (optional): When
true, pending tasks with neitherdueDateTimenorscheduledDateTimeare included in date-range smart filtering. Defaultfalse. - currentDateTime (optional, query:
currentDateTime): Client “now” asdd/MM/yyyy HH:mm. When set,showInListFromis compared tomin(currentDateTime, endDate 23:59)so same-day tasks stay hidden until their visibility window starts (e.g. show from 18:00). When omitted, behavior uses end ofendDateonly (legacy).
Task date fields
dueDate (dueDateTime)
- Represents the deadline of the task.
- The task is pending until that date (and until it is marked done).
Filter rule: If a task has a dueDate and it is on or after startDate, the task should appear in the list, even if dueDate is after endDate. Pending tasks with a future deadline are shown for any range that starts before that deadline.
- Show when:
dueDate != nullANDdueDate >= startDate
showInListFrom (formerly startDueDate)
- Meaning: “Show this task in the list only from this date onwards.”
- Used to avoid showing a task that has a future
dueDateuntil we are within a chosen time window before the deadline (e.g. show only 3 days before due).
Filter rule: A task is shown in a range [startDate, endDate] only if:
showInListFromis null, OR- The “show from” instant is on or before the visibility upper bound for the range:
- If currentDateTime is sent:
showInListFrom <= min(currentDateTime, endDate at 23:59). - If currentDateTime is omitted:
showInListFrom <= endDate at 23:59(end of last day in range).
- If currentDateTime is sent:
So: do not show the task if showInListFrom is after that upper bound (e.g. later the same day when currentDateTime is morning).
scheduledDate (scheduledDateTime)
- Represents a specific date (e.g. “do this on 15th March”).
- The task should appear only on that date (in the UI / filters for that day).
Filter rule:
- On the exact date: If
scheduledDatefalls inside[startDate, endDate], the task is shown. - Overdue scheduled task: If the task has a
scheduledDatein the past and is not done, it is treated as overdue and should appear in all date filters (so the user can still see and complete it), unless “hide overdue” is enabled.- Show when:
(scheduledDate in [startDate, endDate])
OR
(scheduledDate < today AND task not done AND withOverdue == true)
- Show when:
Algorithm
Task inclusion requires passing both the date-range check (dueDate or scheduledDate) and the visibility window check (showInListFrom).
Summary of server logic
For a date range [startDate, endDate] and withOverdue:
-
Due-date tasks:
Show ifdueDate != nullANDdueDate >= startDate(pending until deadline). -
showInListFrom:
Show only ifshowInListFrom == nullORshowInListFrom <=visibility upper bound (min(currentDateTime, endDate 23:59)whencurrentDateTimeis provided, elseendDate 23:59). -
Scheduled-date tasks:
Show if:scheduledDateis in[startDate, endDate], ORscheduledDate < todayAND task not done ANDwithOverdue == true.
-
Undated (optional):
WhenincludeUndated == true, also include pending tasks withdueDateTime == nullANDscheduledDateTime == null. -
Combined:
A task is included in the result if it satisfies the rules for whichever ofdueDate/scheduledDate/showInListFrom/ undated apply (and respectswithOverduefor overdue scheduled tasks).
No-due-date list (GET /tasks/noDueDate)
Tasks with dueDateTime == null (scheduled-only tasks may still appear). Completed tasks with doneDateTime older than 7 days are excluded so the list does not grow unbounded with ancient completions.
Rename: startDueDate → showInListFrom
The property was renamed from startDueDate to showInListFrom to reflect that it controls from when the task is shown in the list, not a “start” of the due period. The database column may remain start_due_date_time for compatibility, or be migrated to a name like show_in_list_from; the API and domain use showInListFrom.