From b47f8f3cbc18fbbbcedd23e9eb6072c51b398cce Mon Sep 17 00:00:00 2001 From: Rerrah Date: Sun, 14 Sep 2025 22:10:41 +0900 Subject: [PATCH 1/2] Change max instrument count in search page --- app/search/defines.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/search/defines.ts b/app/search/defines.ts index a1dbd1d..8922f39 100644 --- a/app/search/defines.ts +++ b/app/search/defines.ts @@ -1,3 +1,3 @@ export const MAX_LIKE_COUNT = 500; -export const PAGE_SIZE = 6; +export const PAGE_SIZE = 18; From 33d8f38119ff8b3388d4cd384d0c76df4213c2e5 Mon Sep 17 00:00:00 2001 From: Rerrah Date: Sun, 14 Sep 2025 22:29:32 +0900 Subject: [PATCH 2/2] Use common instrument search API in top page --- app/page.tsx | 15 +++++++++------ features/instrument/api.ts | 16 ---------------- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/app/page.tsx b/app/page.tsx index a42bea5..4da6969 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1,8 +1,5 @@ import type { Timestamp } from "firebase/firestore"; -import { - getInstrumentDocsAndIdsMostLiked, - getInstrumentDocsAndIdsNewer, -} from "@/features/instrument/api"; +import { searchInstruments } from "@/features/instrument/api"; import { getUidNameTable } from "@/features/user/api"; import { HomePageContent } from "./_components/content"; import type { InstrumentMetaInfo } from "./types"; @@ -11,8 +8,14 @@ const NEW_INSTRUMENT_COUNT = 6; const LIKE_RANKING_COUNT = 5; export default async function HomePage() { - const newest = await getInstrumentDocsAndIdsNewer(NEW_INSTRUMENT_COUNT); - const likes = await getInstrumentDocsAndIdsMostLiked(LIKE_RANKING_COUNT); + const { docs: newest } = await searchInstruments({ + pageSize: NEW_INSTRUMENT_COUNT, + sortBy: "newest", + }); + const { docs: likes } = await searchInstruments({ + pageSize: LIKE_RANKING_COUNT, + sortBy: "likes", + }); const authorUids = [ ...new Set([ diff --git a/features/instrument/api.ts b/features/instrument/api.ts index 769a18e..a112d81 100644 --- a/features/instrument/api.ts +++ b/features/instrument/api.ts @@ -98,22 +98,6 @@ export async function getInstrumentDocsAndIdsByAuthor( return querySnapshot.docs.map((doc) => [doc.data() as InstrumentDoc, doc.id]); } -export async function getInstrumentDocsAndIdsNewer( - limitCount: number -): Promise<[InstrumentDoc, string][]> { - const q = query(collectionInstruments(), orderByNew, limit(limitCount)); - const querySnapshot = await getDocs(q); - return querySnapshot.docs.map((doc) => [doc.data() as InstrumentDoc, doc.id]); -} - -export async function getInstrumentDocsAndIdsMostLiked( - limitCount: number -): Promise<[InstrumentDoc, string][]> { - const q = query(collectionInstruments(), orderByLiked, limit(limitCount)); - const querySnapshot = await getDocs(q); - return querySnapshot.docs.map((doc) => [doc.data() as InstrumentDoc, doc.id]); -} - export async function updateInstrumentDoc( instrumentId: string, metaInfo: EditableInstrumentMetaInfo