Skip to main content
This is the core gamification endpoint. Calling it does three things atomically:
  1. Creates a TaskCompletion record.
  2. Adds the task’s points value to the user’s total points.
  3. If this is the user’s first completion of the day, increments current_streak and updates max_streak if 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.
The streak counter only goes up at completion time. Whether yesterday’s streak should be broken is evaluated by an overnight cron job, not in real time. This means current_streak may appear higher than expected until the cron runs. If you need to check whether a streak is still valid, compare current_streak against the user’s last-completion timestamp.

Request body

number
required
ID of the task being completed.

Response

201 Created — Returns the new task completion record.
number
required
Auto-incremented unique identifier for this completion record.
number
required
ID of the task that was completed.
string
required
UUID of the user who completed the task.
string
required
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:

Streak logic

The exact logic executed in taskCompletion.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