Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions app/page.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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([
Expand Down
2 changes: 1 addition & 1 deletion app/search/defines.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const MAX_LIKE_COUNT = 500;

export const PAGE_SIZE = 6;
export const PAGE_SIZE = 18;
16 changes: 0 additions & 16 deletions features/instrument/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down