Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

update scripts & gitignore

Steven Tey738bd405e780
diff --git a/.gitignore b/.gitignore
index b5cee4ed5f..dba2ab1b6b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -41,4 +41,5 @@ next-env.d.ts
.react-email
.contentlayer
.vscode
-*.csv
\ No newline at end of file
+*.csv
+*.ndjson
\ No newline at end of file
diff --git a/apps/web/scripts/get-active-projects.ts b/apps/web/scripts/get-projects-by-clicks.ts
similarity index 100%
rename from apps/web/scripts/get-active-projects.ts
rename to apps/web/scripts/get-projects-by-clicks.ts
diff --git a/apps/web/scripts/get-projects-by-links.ts b/apps/web/scripts/get-projects-by-links.ts
new file mode 100644
index 0000000000..9084756b8a
--- /dev/null
+++ b/apps/web/scripts/get-projects-by-links.ts
@@ -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();