Merge pull request #68 from quantified-uncertainty/frontend-ids

Fix for frontpage table refactoring
This commit is contained in:
Vyacheslav Matyukhin 2022-04-23 00:13:08 +03:00 committed by GitHub
commit 2b5b6bf42b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 10 deletions

View File

@ -3,13 +3,13 @@ import { PrismaClient } from "@prisma/client";
declare global { declare global {
// allow global `var` declarations // allow global `var` declarations
// eslint-disable-next-line no-var // eslint-disable-next-line no-var
var prisma: PrismaClient | undefined; var _prisma: PrismaClient | undefined;
} }
export const prisma = export const prisma =
global.prisma || global._prisma ||
new PrismaClient({ new PrismaClient({
log: ["query"], log: ["query"],
}); });
if (process.env.NODE_ENV !== "production") global.prisma = prisma; if (process.env.NODE_ENV !== "production") global._prisma = prisma;

View File

@ -1,16 +1,18 @@
import { Question } from "@prisma/client"; import { Question } from "@prisma/client";
import { prisma } from "./database/prisma";
import { measureTime } from "./utils/measureTime"; import { measureTime } from "./utils/measureTime";
export async function getFrontpage(): Promise<Question[]> { export async function getFrontpage(): Promise<Question[]> {
const questions = await prisma.question.findMany({ const questions = (
where: { await prisma.frontpageId.findMany({
onFrontpage: { include: {
isNot: null, question: true,
}, },
}, })
}); )
console.log(questions.length); .map((f) => f.question)
.filter((q) => q);
return questions; return questions;
} }