diff --git a/src/app/lib/persistence.ts b/src/app/lib/persistence.ts index 1eca13d..a6a1c6a 100644 --- a/src/app/lib/persistence.ts +++ b/src/app/lib/persistence.ts @@ -4,7 +4,7 @@ import { getAllPostsVotesMoarBetter, } from "./data"; import db from "../db"; -import { hasAi } from "../utils/string"; +import { hasAi, PRODUCT_HUNT_NAME } from "../utils/string"; import { Post as PostType } from "../types"; import { Prisma } from "@prisma/client"; import { getStartAndEndOfDayInUTC } from "../utils/date"; @@ -153,7 +153,7 @@ export async function fetchAndUpdateDatabase() { await db.post.updateMany({ where: { id: { - notIn: posts.map((post) => post.id), + notIn: posts.filter((product) => product.name !== PRODUCT_HUNT_NAME).map((post) => post.id), }, deleted: false, }, diff --git a/src/app/utils/string.ts b/src/app/utils/string.ts index b026e7c..9e6d3e5 100644 --- a/src/app/utils/string.ts +++ b/src/app/utils/string.ts @@ -1,5 +1,7 @@ import { ProductPost } from "../types"; +export const PRODUCT_HUNT_NAME = "OGHUNT"; + export const hasAi = ( post: { name: ProductPost["name"]; @@ -9,7 +11,7 @@ export const hasAi = ( }, showOnlyAi = false, ): boolean => { - if (post.name === "OGHUNT") { + if (post.name === PRODUCT_HUNT_NAME) { return !showOnlyAi; }