From c2144c78fb09caffd4afc9a02fccd77317da1f83 Mon Sep 17 00:00:00 2001 From: tylerslaton Date: Tue, 19 Mar 2024 15:41:16 -0400 Subject: [PATCH] feat: add loading spinner for search and limit number of reindexes per hour Signed-off-by: tylerslaton --- src/lib/db.ts | 5 +++-- src/pages/search.vue | 13 ++++++++++++- src/server/api/[...slug].post.ts | 10 +++++++++- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/lib/db.ts b/src/lib/db.ts index 5553af8..318d67f 100644 --- a/src/lib/db.ts +++ b/src/lib/db.ts @@ -4,7 +4,7 @@ import { PrismaClient, Prisma } from '@prisma/client'; const prisma = new PrismaClient(); -export const getToolsForUrl = async (url: string): Promise<{ tools: Tool[], examples: ToolExample[] }> => { +export const getToolsForUrl = async (url: string): Promise<{ tools: Tool[], examples: ToolExample[], lastIndexedAt: Date }> => { const toolEntry = await prisma.toolEntry.findFirst({ where: { reference: url @@ -15,11 +15,12 @@ export const getToolsForUrl = async (url: string): Promise<{ tools: Tool[], exam }); if (!toolEntry) { - return { tools: [], examples: [] }; + return { tools: [], examples: [], lastIndexedAt: new Date() }; } return { tools: toolEntry.content as Tool[], + lastIndexedAt: toolEntry.lastIndexedAt, examples: toolEntry.examples.map((example) => ({ name: example.name, url: example.url, diff --git a/src/pages/search.vue b/src/pages/search.vue index 32f70db..9b23c90 100644 --- a/src/pages/search.vue +++ b/src/pages/search.vue @@ -1,6 +1,6 @@