mirror of
https://github.com/bitbaum/evig.git
synced 2026-12-05 01:27:39 +01:00
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:
1 parent
f07cfe3e4d
commit
0692f10da7
1 file changed
+6
-5
@@ -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`
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user