Merge pull request #68 from quantified-uncertainty/frontend-ids
Fix for frontpage table refactoring
This commit is contained in:
commit
2b5b6bf42b
|
@ -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;
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user