Skip to content

Commit e1a767e

Browse files
jakechen1claude
andcommitted
Fix: use explicit select in publications/software to avoid curationStatus
Prisma 7 with libSQL adapter doesn't create curationStatus column in the SQLite schema even though it's in schema.prisma. Using explicit select to only query columns that exist in the deployed database. All publications shown (all are VERIFIED in the data). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent f20edb0 commit e1a767e

2 files changed

Lines changed: 14 additions & 26 deletions

File tree

src/app/api/publications/route.ts

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,7 @@
11
import { NextRequest, NextResponse } from "next/server"
2-
import { prisma, getDbDiagnostics } from "@/lib/db"
3-
import { statSync, readdirSync } from "fs"
4-
import { resolve, join } from "path"
2+
import { prisma } from "@/lib/db"
53

64
export async function GET(request: NextRequest) {
7-
// Debug: try a raw query first
8-
const { searchParams: sp } = new URL(request.url)
9-
if (sp.get("debug") === "1") {
10-
try {
11-
const raw = await prisma.$queryRawUnsafe("SELECT COUNT(*) as cnt FROM Publication") as Array<{cnt: number}>
12-
const cols = await prisma.$queryRawUnsafe("PRAGMA table_info(Publication)") as Array<Record<string, unknown>>
13-
return NextResponse.json({ rawCount: raw, columns: cols })
14-
} catch (e) {
15-
return NextResponse.json({ debugError: e instanceof Error ? e.message : String(e) })
16-
}
17-
}
18-
195
try {
206
const { searchParams } = new URL(request.url)
217
const search = searchParams.get("search") || ""
@@ -25,9 +11,7 @@ export async function GET(request: NextRequest) {
2511
const page = parseInt(searchParams.get("page") || "1")
2612
const limit = parseInt(searchParams.get("limit") || "20")
2713

28-
const where: Record<string, unknown> = {
29-
curationStatus: "VERIFIED",
30-
}
14+
const where: Record<string, unknown> = {}
3115

3216
if (search) {
3317
where.OR = [
@@ -46,6 +30,12 @@ export async function GET(request: NextRequest) {
4630
orderBy: { year: "desc" },
4731
skip: (page - 1) * limit,
4832
take: limit,
33+
select: {
34+
id: true, title: true, authors: true, year: true, journal: true,
35+
abstract: true, doi: true, pubmedId: true, arxivId: true, pdfUrl: true,
36+
tags: true, researchLineage: true, articleType: true, featured: true,
37+
createdAt: true, updatedAt: true,
38+
},
4939
}),
5040
prisma.publication.count({ where }),
5141
])
@@ -59,15 +49,8 @@ export async function GET(request: NextRequest) {
5949
} catch (error) {
6050
const msg = error instanceof Error ? error.message : String(error)
6151
console.error("Failed to fetch publications:", msg)
62-
// Debug: check what db files exist on disk
63-
const dbPath = getDbDiagnostics().activePath
64-
let fileSize = 0
65-
try { fileSize = statSync(dbPath).size } catch {}
66-
let cwdFiles: string[] = []
67-
try { cwdFiles = readdirSync(process.cwd()).filter(f => f.includes('.db') || f.includes('aimed')) } catch {}
68-
6952
return NextResponse.json(
70-
{ error: "Failed to fetch publications", detail: msg, db: { ...getDbDiagnostics(), fileSize, cwdFiles } },
53+
{ error: "Failed to fetch publications", detail: msg },
7154
{ status: 500 }
7255
)
7356
}

src/app/api/software/route.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ export async function GET() {
55
try {
66
const software = await prisma.softwareResource.findMany({
77
orderBy: { id: "desc" },
8+
select: {
9+
id: true, name: true, description: true, url: true, githubUrl: true,
10+
screenshotUrl: true, relatedPapers: true, category: true, featured: true,
11+
createdAt: true, updatedAt: true,
12+
},
813
})
914
return NextResponse.json({ software, total: software.length })
1015
} catch (error) {

0 commit comments

Comments
 (0)