forked from dubinc/dub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4c085b2
commit eda4c06
Showing
7 changed files
with
1,358 additions
and
248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import "dotenv-flow/config"; | ||
import prisma from "@/lib/prisma"; | ||
|
||
async function main() { | ||
const projects = await prisma.project.findMany({ | ||
select: { | ||
slug: true, | ||
plan: true, | ||
usage: true, | ||
domains: { | ||
select: { | ||
slug: true, | ||
}, | ||
}, | ||
_count: { | ||
select: { | ||
links: true, | ||
domains: true, | ||
}, | ||
}, | ||
}, | ||
orderBy: { | ||
usage: "desc", | ||
}, | ||
take: 100, | ||
}); | ||
console.table( | ||
projects.map((project) => ({ | ||
...project, | ||
domains: `${ | ||
project.domains | ||
.slice(0, 2) | ||
.map((domain) => domain.slug) | ||
.join(", ") + | ||
(project.domains.length > 2 ? `... ${project._count.domains - 2}+` : "") | ||
}`, | ||
})), | ||
); | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import "dotenv-flow/config"; | ||
import prisma from "@/lib/prisma"; | ||
|
||
async function main() { | ||
const users = await prisma.user.findMany({ | ||
where: { | ||
tokens: { | ||
some: {}, | ||
}, | ||
}, | ||
}); | ||
console.log(users.map((user) => user.email).join(", ")); | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import "dotenv-flow/config"; | ||
import prisma from "@/lib/prisma"; | ||
|
||
async function main() { | ||
const [users, count] = await Promise.all([ | ||
prisma.user.findMany({ | ||
where: { | ||
projects: { | ||
none: {}, | ||
}, | ||
links: { | ||
none: {}, | ||
}, | ||
}, | ||
select: { | ||
email: true, | ||
createdAt: true, | ||
_count: { | ||
select: { | ||
projects: true, | ||
links: true, | ||
}, | ||
}, | ||
}, | ||
orderBy: { createdAt: "asc" }, | ||
take: 100, | ||
}), | ||
prisma.user.count({ | ||
where: { | ||
projects: { | ||
none: {}, | ||
}, | ||
links: { | ||
none: {}, | ||
}, | ||
}, | ||
}), | ||
]); | ||
// log in table format | ||
console.table(users); | ||
console.log(`Total: ${count}`); | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// runner.ts | ||
import { exec } from "child_process"; | ||
|
||
const command: string = process.argv[2]; | ||
|
||
if (!command) { | ||
console.error("Please provide a command name."); | ||
process.exit(1); | ||
} | ||
|
||
const scriptPath = `./scripts/${command}.ts`; | ||
|
||
exec(`tsx ${scriptPath}`, (error, stdout, stderr) => { | ||
if (error) { | ||
console.error(`Error executing script: ${error.message}`); | ||
return; | ||
} | ||
console.log(stdout); | ||
console.error(stderr); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.