Skip to content

Commit

Permalink
update scripts & gitignore
Browse files Browse the repository at this point in the history
  • Loading branch information
steven-tey committed Jan 9, 2024
1 parent c25cc2a commit 738bd40
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ next-env.d.ts
.react-email
.contentlayer
.vscode
*.csv
*.csv
*.ndjson
File renamed without changes.
46 changes: 46 additions & 0 deletions apps/web/scripts/get-projects-by-links.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import "dotenv-flow/config";
import prisma from "@/lib/prisma";

async function main() {
const projects = await prisma.link
.groupBy({
by: ["projectId"],
_count: {
id: true,
},
orderBy: {
_count: {
id: "desc",
},
},
take: 100,
})
.then(
async (projects) =>
await Promise.all(
projects.map(async ({ _count, projectId }) => {
if (!projectId) {
return;
}
const project = await prisma.project.findUnique({
where: {
id: projectId,
},
select: {
slug: true,
plan: true,
},
});
return {
project: project?.slug,
plan: project?.plan,
links: _count.id,
};
}),
),
);

console.table(projects);
}

main();

0 comments on commit 738bd40

Please sign in to comment.