Add installs from DB
This commit is contained in:
parent
84967e5cdf
commit
80a0ad98b1
|
@ -19,6 +19,7 @@ export default function AllApps({ apps }: { apps: App[] }) {
|
|||
logo={app.logo}
|
||||
rating={app.rating}
|
||||
reviews={app.reviews}
|
||||
installs={app.installs}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
|
|
@ -11,9 +11,12 @@ interface AppCardProps {
|
|||
description: string;
|
||||
rating: number;
|
||||
reviews?: number;
|
||||
installs?: number;
|
||||
}
|
||||
|
||||
export default function AppCard(props: AppCardProps) {
|
||||
console.log("🚀 ~ file: AppCard.tsx ~ line 16 ~ installs", props.installs);
|
||||
|
||||
return (
|
||||
<Link href={"/apps/" + props.slug}>
|
||||
<a
|
||||
|
|
|
@ -25,15 +25,31 @@ export default function Apps({ appStore, categories }: InferGetStaticPropsType<t
|
|||
}
|
||||
|
||||
export const getStaticProps = async () => {
|
||||
const appStore = await getAppRegistry();
|
||||
const appMetaData = await getAppRegistry();
|
||||
|
||||
const categoryQuery = await prisma.app.findMany({
|
||||
const appsQuery = await prisma.app.findMany({
|
||||
select: {
|
||||
slug: true,
|
||||
categories: true,
|
||||
_count: {
|
||||
select: {
|
||||
credentials: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
const categories = categoryQuery.reduce((c, app) => {
|
||||
for (const category of app.categories) {
|
||||
console.log("🚀 ~ file: index.tsx ~ line 40 ~ getStaticProps ~ appsQuery", appsQuery);
|
||||
|
||||
const appStore = appMetaData.map((app) => {
|
||||
const installs = appsQuery.filter((query) => query.slug === app.slug);
|
||||
console.log("🚀 ~ file: index.tsx ~ line 45 ~ appStore ~ installs", installs[0]._count.credentials);
|
||||
|
||||
return { ...app, installs: installs[0]._count.credentials };
|
||||
});
|
||||
|
||||
const categoriesArray = appsQuery.map((app) => app.categories);
|
||||
const categories = categoriesArray.reduce((c, app) => {
|
||||
for (const category of app) {
|
||||
c[category] = c[category] ? c[category] + 1 : 1;
|
||||
}
|
||||
return c;
|
||||
|
|
|
@ -73,4 +73,6 @@ export interface App {
|
|||
price?: number;
|
||||
/** only required for "usage-based" billing. % of commission for paid bookings */
|
||||
commission?: number;
|
||||
/** Query from db, count the number of credentials */
|
||||
installs?: number;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user