Add task priority enum and rename priority to rank

The existing integer priority field represents positional ordering
within a state, not semantic importance. Rename it to rank and
introduce a new priority field with enum values URGENT, HIGH,
MEDIUM and LOW across the entire stack.

Rank is now scoped to (state, priority) so tasks are ordered
within each priority group. A generated priority_rank column
combines both fields into a single sortable integer for cursor
pagination.

Dragging a task across priority groups updates its priority
automatically based on the drop position neighbors. The backend
first moves the task to the new group then repositions it at the
target rank.

The migration defaults existing rows to MEDIUM priority and
backfills ranks per (state, priority) group.

Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
Sacha Al Himdani
2026-03-30 17:12:03 +02:00
parent a2f0a37b7b
commit 324f4ce793
21 changed files with 444 additions and 87 deletions

View File

@@ -58,6 +58,7 @@ func TestTask_Create(t *testing.T) {
"measureId": measureID,
"name": "Owner Task",
"description": "Created by owner",
"priority": "MEDIUM",
},
}, &result)
require.NoError(t, err)
@@ -106,6 +107,7 @@ func TestTask_CreateWithoutMeasure(t *testing.T) {
"organizationId": owner.GetOrganizationID().String(),
"name": "Task without measure",
"description": "Created without a measure",
"priority": "HIGH",
},
}, &result)
require.NoError(t, err)
@@ -252,7 +254,8 @@ func TestTask_RequiredFields(t *testing.T) {
{
name: "missing organizationId",
input: map[string]any{
"name": "Test Task",
"name": "Test Task",
"priority": "MEDIUM",
},
skipOrganization: true,
wantErrorContains: "organizationId",
@@ -261,9 +264,18 @@ func TestTask_RequiredFields(t *testing.T) {
name: "missing name",
input: map[string]any{
"organizationId": "placeholder",
"priority": "MEDIUM",
},
wantErrorContains: "name",
},
{
name: "missing priority",
input: map[string]any{
"organizationId": "placeholder",
"name": "Test Task",
},
wantErrorContains: "priority",
},
}
for _, tt := range tests {
@@ -770,6 +782,7 @@ func TestTask_OmittableDeadline(t *testing.T) {
"organizationId": owner.GetOrganizationID().String(),
"measureId": measureID,
"name": "Deadline Test Task",
"priority": "MEDIUM",
"deadline": "2025-12-31T00:00:00Z",
},
}, &createResult)