- Creates a
TaskCompletionrecord. - Adds the task’s
pointsvalue to the user’s totalpoints. - If this is the user’s first completion of the day, increments
current_streakand updatesmax_streakif the new streak exceeds the previous record.
The streak counter increments once per calendar day, on the first task completion of that day — regardless of which task is completed. Completing multiple tasks on the same day does not increment the streak more than once.
Request body
ID of the task being completed.
Response
201 Created — Returns the new task completion record.Auto-incremented unique identifier for this completion record.
ID of the task that was completed.
UUID of the user who completed the task.
ISO 8601 timestamp set to the server time at the moment of completion.
Side effects
The following changes are applied to the user’s profile as part of the same request:| Field | Change |
|---|---|
points | Increased by task.points. |
current_streak | Incremented by 1 if this is the first completion today; unchanged otherwise. |
max_streak | Updated to current_streak if the new streak exceeds the stored record. |
Streak logic
The exact logic executed intaskCompletion.service.ts:
findByUserIdToday queries completions where completed_at >= CURRENT_DATE AND completed_at < CURRENT_DATE + INTERVAL '1 day', so “today” is always the server’s current calendar date in UTC.
There is no unique constraint on
(user_id, task_id, date) in the database schema. The same task can be completed multiple times on the same day. Each call creates a new completion record and awards points again. Only the streak counter is bounded to once per day.Errors
| Status | Condition |
|---|---|
404 | No task found with the given task_id. |
400 | The task exists but belongs to a different user. |
401 | Missing or invalid authentication token. |