From 9043a40fc80bb2f30717bae029b17391c6f9f636 Mon Sep 17 00:00:00 2001 From: typesafeui Date: Tue, 27 Aug 2024 18:13:44 +0200 Subject: [PATCH 1/4] W Persistence --- src/app/lib/persistence.ts | 4 ++-- src/app/utils/string.ts | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/app/lib/persistence.ts b/src/app/lib/persistence.ts index 1eca13d..6a5656a 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..de50867 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,8 +11,8 @@ export const hasAi = ( }, showOnlyAi = false, ): boolean => { - if (post.name === "OGHUNT") { - return !showOnlyAi; + if (post.name === PRODUCT_HUNT_NAME) { + return false; } const excludedTerms = ["ai", "gpt", "artificial intelligence", "machine learning"]; From b2c1459fd2877b6622cfe980cd3e85fd022383f2 Mon Sep 17 00:00:00 2001 From: typesafeui Date: Tue, 27 Aug 2024 18:17:57 +0200 Subject: [PATCH 2/4] W format --- src/app/lib/persistence.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/lib/persistence.ts b/src/app/lib/persistence.ts index 6a5656a..1fd7e42 100644 --- a/src/app/lib/persistence.ts +++ b/src/app/lib/persistence.ts @@ -153,7 +153,7 @@ export async function fetchAndUpdateDatabase() { await db.post.updateMany({ where: { id: { - notIn: posts.filter(product=>product.name === PRODUCT_HUNT_NAME).map((post) => post.id), + notIn: posts.filter((product) => product.name === PRODUCT_HUNT_NAME).map((post) => post.id), }, deleted: false, }, From a0b6fabf51995d37022eb5225169719bc446c236 Mon Sep 17 00:00:00 2001 From: typesafeui Date: Tue, 27 Aug 2024 18:21:44 +0200 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=92=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/utils/string.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/utils/string.ts b/src/app/utils/string.ts index de50867..9e6d3e5 100644 --- a/src/app/utils/string.ts +++ b/src/app/utils/string.ts @@ -12,7 +12,7 @@ export const hasAi = ( showOnlyAi = false, ): boolean => { if (post.name === PRODUCT_HUNT_NAME) { - return false; + return !showOnlyAi; } const excludedTerms = ["ai", "gpt", "artificial intelligence", "machine learning"]; From 66f7b8184a0c88bca58722fe602ed198ef51ac1f Mon Sep 17 00:00:00 2001 From: typesafeui Date: Tue, 27 Aug 2024 18:23:34 +0200 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=92=80=20pt.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/lib/persistence.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/lib/persistence.ts b/src/app/lib/persistence.ts index 1fd7e42..a6a1c6a 100644 --- a/src/app/lib/persistence.ts +++ b/src/app/lib/persistence.ts @@ -153,7 +153,7 @@ export async function fetchAndUpdateDatabase() { await db.post.updateMany({ where: { id: { - notIn: posts.filter((product) => product.name === PRODUCT_HUNT_NAME).map((post) => post.id), + notIn: posts.filter((product) => product.name !== PRODUCT_HUNT_NAME).map((post) => post.id), }, deleted: false, },