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.

Enhance E2E cleanup route to remove tags along with links and domains

Kiran K194583031209
diff --git a/apps/web/app/api/cron/cleanup/route.ts b/apps/web/app/api/cron/cleanup/route.ts
index d90c37791d..5fb9d2a291 100644
--- a/apps/web/app/api/cron/cleanup/route.ts
+++ b/apps/web/app/api/cron/cleanup/route.ts
@@ -12,7 +12,7 @@ const E2E_USER_ID = "clxz1q7c7000hbqx5ckv4r82h";
const E2E_WORKSPACE_ID = "clrei1gld0002vs9mzn93p8ik";
/***
- This route is used to remove links and domains created during the E2E test.
+ This route is used to remove links, domains and tags created during the E2E test.
Runs every 6 hours (0 * / 6 * * *)
*/
export async function GET(req: Request) {
@@ -21,7 +21,7 @@ export async function GET(req: Request) {
const oneHourAgo = new Date(Date.now() - 1000 * 60 * 60);
- const [links, domains] = await Promise.all([
+ const [links, domains, tags] = await Promise.all([
prisma.link.findMany({
where: {
userId: E2E_USER_ID,
@@ -54,6 +54,18 @@ export async function GET(req: Request) {
slug: true,
},
}),
+
+ prisma.tag.findMany({
+ where: {
+ projectId: E2E_WORKSPACE_ID,
+ name: {
+ startsWith: "e2e-",
+ },
+ createdAt: {
+ lt: oneHourAgo,
+ },
+ },
+ }),
]);
// Delete the links
@@ -82,7 +94,20 @@ export async function GET(req: Request) {
);
}
- console.log(`Removed ${links.length} links and ${domains.length} domains`);
+ // Delete the tags
+ if (tags.length > 0) {
+ await prisma.tag.deleteMany({
+ where: {
+ id: {
+ in: tags.map((tag) => tag.id),
+ },
+ },
+ });
+ }
+
+ console.log(
+ `Removed ${links.length} links, ${domains.length} domains and ${tags.length} tags`,
+ );
return NextResponse.json({ status: "OK" });
} catch (error) {