diff --git a/backend/src/routes/experiments.js b/backend/src/routes/experiments.js index 1db58e1..2581c29 100644 --- a/backend/src/routes/experiments.js +++ b/backend/src/routes/experiments.js @@ -1,6 +1,5 @@ const router = require('express').Router(); const { body } = require('express-validator'); -const { Prisma } = require('@prisma/client'); const prisma = require('../lib/prisma'); const cache = require('../lib/cache'); const auditMiddleware = require('../middleware/auditMiddleware'); @@ -373,11 +372,8 @@ router.get('/:id/daily-statuses', async (req, res, next) => { const next = new Date(d); next.setUTCDate(next.getUTCDate() + 1); where.date = { gte: d, lt: next }; } - if (analysisOnly) { - where.NOT = { analysis_summary: Prisma.DbNull }; - } - const statuses = await prisma.dailyStatus.findMany({ + let statuses = await prisma.dailyStatus.findMany({ where, select: { id: true, @@ -393,6 +389,12 @@ router.get('/:id/daily-statuses', async (req, res, next) => { orderBy: { date: 'asc' }, }); + // Prisma 5 has no clean IS NOT NULL filter for Json? fields; filter in JS. + // The result is cached so this only runs once per cache period. + if (analysisOnly) { + statuses = statuses.filter((s) => s.analysis_summary !== null); + } + cache.set(cacheKey, statuses); res.json(statuses); } catch (err) { next(err); }