Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .claude/scheduled_tasks.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"sessionId":"203762cd-147b-4e60-a6be-2c87c976a77a","pid":3111,"procStart":"Sun May 10 08:20:28 2026","acquiredAt":1778404006554}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
node_modules/
.env
.env.local
.next/
next-env.d.ts
*.tsbuildinfo
.DS_Store
17 changes: 17 additions & 0 deletions app/api/sessions/[id]/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { NextRequest, NextResponse } from 'next/server';
import { connectMongo } from '@/lib/db/mongoose';
import { SessionModel } from '@/lib/db/models';

export const dynamic = 'force-dynamic';

export async function GET(_req: NextRequest, { params }: { params: { id: string } }) {
await connectMongo();
try {
const session = await SessionModel.findById(params.id).lean();
if (!session) return NextResponse.json({ error: 'Session not found' }, { status: 404 });
return NextResponse.json(session);
} catch (err) {
console.error('Error fetching session:', err);
return NextResponse.json({ error: 'Failed to fetch session' }, { status: 500 });
}
}
43 changes: 43 additions & 0 deletions app/api/sessions/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { NextRequest, NextResponse } from 'next/server';
import { connectMongo } from '@/lib/db/mongoose';
import { SessionModel } from '@/lib/db/models';

export const dynamic = 'force-dynamic';

export async function GET() {
await connectMongo();
const sessions = await SessionModel.find().sort({ savedAt: -1 }).lean();
return NextResponse.json(sessions);
}

export async function POST(req: NextRequest) {
await connectMongo();
const body = await req.json();
const { participantId, submittedAt, successCount, failureCount, totalTrials, successRate, trials } = body;

if (
submittedAt === undefined ||
successCount === undefined ||
failureCount === undefined ||
totalTrials === undefined ||
successRate === undefined
) {
return NextResponse.json({ error: 'Missing required fields' }, { status: 400 });
}

try {
const session = await SessionModel.create({
participantId: participantId || '',
submittedAt: new Date(submittedAt),
successCount,
failureCount,
totalTrials,
successRate,
trials: trials || [],
});
return NextResponse.json({ status: 'ok', sessionId: session._id }, { status: 201 });
} catch (err) {
console.error('Error saving session:', err);
return NextResponse.json({ error: 'Failed to save results' }, { status: 500 });
}
}
Loading