From bd0730b981833b08230aae5e222f34d2925d7d4d Mon Sep 17 00:00:00 2001 From: Xeu Date: Wed, 4 Dec 2024 01:54:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20#268=20=E5=AD=97=E6=AE=B5=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=E4=B8=8E=E5=8F=98=E9=87=8F=E5=90=8D=E7=A7=B0=E5=86=B2?= =?UTF-8?q?=E7=AA=81=E5=AF=BC=E8=87=B4=20cpu=20exceeded=20time=20Signed-of?= =?UTF-8?q?f-by:=20Xeu=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/services/feed.ts | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/server/src/services/feed.ts b/server/src/services/feed.ts index 846f8027..91f0b9e2 100644 --- a/server/src/services/feed.ts +++ b/server/src/services/feed.ts @@ -1,14 +1,14 @@ -import { and, count, desc, eq, like, or } from "drizzle-orm"; -import Elysia, { t } from "elysia"; -import { XMLParser } from "fast-xml-parser"; +import {and, count, desc, eq, like, or} from "drizzle-orm"; +import Elysia, {t} from "elysia"; +import {XMLParser} from "fast-xml-parser"; import html2md from 'html-to-md'; -import type { DB } from "../_worker"; -import { feeds, visits } from "../db/schema"; -import { setup } from "../setup"; -import { ClientConfig, PublicCache } from "../utils/cache"; -import { getDB } from "../utils/di"; -import { extractImage } from "../utils/image"; -import { bindTagToPost } from "./tag"; +import type {DB} from "../_worker"; +import {feeds, visits} from "../db/schema"; +import {setup} from "../setup"; +import {ClientConfig, PublicCache} from "../utils/cache"; +import {getDB} from "../utils/di"; +import {extractImage} from "../utils/image"; +import {bindTagToPost} from "./tag"; export function FeedService() { const db: DB = getDB(); @@ -324,12 +324,12 @@ export function FeedService() { } const cacheKey = `search_${keyword}`; const searchKeyword = `%${keyword}%`; - const where = or(like(feeds.title, searchKeyword), + const whereClause = or(like(feeds.title, searchKeyword), like(feeds.content, searchKeyword), - like(feeds.summary, searchKeyword), - like(feeds.alias, searchKeyword)); + like(feeds.summary, searchKeyword), + like(feeds.alias, searchKeyword)); const feed_list = (await cache.getOrSet(cacheKey, () => db.query.feeds.findMany({ - where: admin ? where : and(where, eq(feeds.draft, 0)), + where: admin ? whereClause : and(whereClause, eq(feeds.draft, 0)), columns: admin ? undefined : { draft: false, listed: false