refactor(tasks): replace hardcoded status strings with PROJECT_STATUSES constants

Eliminates SSOT violation in the task-projects GET route ORDER BY clause.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
g-butandClaude Sonnet 4.6 committed 2026-05-03 04:42:04 +02:00
1 parent f07cfe3e4d
commit 0692f10da7
1 file changed
+6 -5
+6 -5
View File
@@ -14,6 +14,7 @@ import { db } from '@/db';
import { taskProjects, tasks, users } from '@/db/schema';
import { eq, sql, and, not } from 'drizzle-orm';
import { createProjectSchema } from '@/lib/schemas/tasks';
import { PROJECT_STATUSES } from '@/config/tasks';
import { logger } from '@/lib/logger';
/**
@@ -53,11 +54,11 @@ export const GET = withAdmin(async (request: NextRequest, session: ValidSession)
.where(conditions.length > 0 ? and(...conditions) : undefined)
.orderBy(
sql`CASE ${taskProjects.status}
WHEN 'active' THEN 0
WHEN 'planning' THEN 1
WHEN 'on_hold' THEN 2
WHEN 'completed' THEN 3
WHEN 'cancelled' THEN 4
WHEN ${PROJECT_STATUSES.ACTIVE} THEN 0
WHEN ${PROJECT_STATUSES.PLANNING} THEN 1
WHEN ${PROJECT_STATUSES.ON_HOLD} THEN 2
WHEN ${PROJECT_STATUSES.COMPLETED} THEN 3
WHEN ${PROJECT_STATUSES.CANCELLED} THEN 4
END`,
sql`${taskProjects.createdAt} DESC`
)