MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / PATCH

Function PATCH

web/src/app/api/git-evals/visibility/route.ts:11–61  ·  view source on GitHub ↗
(request: NextRequest)

Source from the content-addressed store, hash-verified

9import { logger } from '@/util/logger'
10
11export async function PATCH(request: NextRequest) {
12 try {
13 // Check admin authentication
14 const authResult = await checkAdminAuth()
15 if (authResult instanceof NextResponse) {
16 return authResult
17 }
18
19 const body = await request.json()
20 const { id, is_public } = body
21
22 // Validate request body
23 if (!id || typeof is_public !== 'boolean') {
24 return NextResponse.json(
25 { error: 'Missing or invalid required fields: id, is_public' },
26 { status: 400 },
27 )
28 }
29
30 // Update the eval result visibility
31 const [updatedResult] = await db
32 .update(schema.gitEvalResults)
33 .set({ is_public })
34 .where(eq(schema.gitEvalResults.id, id))
35 .returning()
36
37 if (!updatedResult) {
38 return NextResponse.json(
39 { error: 'Eval result not found' },
40 { status: 404 },
41 )
42 }
43
44 logger.info(
45 {
46 evalResultId: id,
47 is_public,
48 adminUserId: authResult.id,
49 },
50 'Updated eval result visibility',
51 )
52
53 return NextResponse.json(updatedResult)
54 } catch (error) {
55 logger.error({ error }, 'Error updating eval result visibility')
56 return NextResponse.json(
57 { error: 'Internal server error' },
58 { status: 500 },
59 )
60 }
61}

Callers

nothing calls this directly

Calls 2

checkAdminAuthFunction · 0.90
setMethod · 0.80

Tested by

no test coverage detected