From 17af50bbdc285ab86f0c205e79c1daa70415f483 Mon Sep 17 00:00:00 2001 From: Hariom Balhara <1780212+hariombalhara@users.noreply.github.com> Date: Fri, 27 Feb 2026 00:21:11 +0530 Subject: [PATCH] feat: add per-host locations seed data in Acme Org for QA (#27832) * fix: host location option * feat: add per-host locations seed data for Round Robin event type Co-Authored-By: hariom@cal.com * refactor: move per-host locations seed to Acme Org with dedicated event type Co-Authored-By: hariom@cal.com * fix: check app existence before creating credentials in per-host location seed Co-Authored-By: hariom@cal.com * refactor: remove credential-based app seeding, use simple location types instead Co-Authored-By: hariom@cal.com --------- Co-authored-by: Udit Takkar Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com> --- scripts/seed.ts | 104 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) diff --git a/scripts/seed.ts b/scripts/seed.ts index 7279301bdf..8ee0afecac 100644 --- a/scripts/seed.ts +++ b/scripts/seed.ts @@ -693,6 +693,109 @@ async function ensureAcmeOwnerHasApiKeySeeded() { } } +async function seedPerHostLocationsInAcmeOrg() { + const acmeOrg = await prisma.team.findFirst({ + where: { slug: "acme", parentId: null }, + select: { id: true }, + }); + if (!acmeOrg) { + console.log("Acme org not found, skipping per-host location seeding."); + return; + } + + const acmeTeam = await prisma.team.findFirst({ + where: { slug: "team1", parentId: acmeOrg.id }, + select: { id: true }, + }); + if (!acmeTeam) { + console.log("Acme Team 1 not found, skipping per-host location seeding."); + return; + } + + const existingEvent = await prisma.eventType.findFirst({ + where: { slug: "per-host-location-event", teamId: acmeTeam.id }, + }); + if (existingEvent) { + console.log("Per-host location event already seeded in Acme, skipping."); + return; + } + + const owner = await prisma.user.findFirst({ + where: { email: "owner1-acme@example.com" }, + select: { id: true }, + }); + const member0 = await prisma.user.findFirst({ + where: { email: "member0-acme@example.com" }, + select: { id: true }, + }); + const member2 = await prisma.user.findFirst({ + where: { email: "member2-acme@example.com" }, + select: { id: true }, + }); + if (!owner || !member0 || !member2) { + console.log("Required Acme members not found, skipping per-host location seeding."); + return; + } + + const hosts = [owner, member0, member2]; + + const ownerProfile = await prisma.profile.findFirst({ + where: { userId: owner.id, organizationId: acmeOrg.id }, + select: { id: true }, + }); + + const eventType = await prisma.eventType.create({ + data: { + title: "Per Host Location Event", + slug: "per-host-location-event", + length: 30, + schedulingType: SchedulingType.ROUND_ROBIN, + enablePerHostLocations: true, + team: { connect: { id: acmeTeam.id } }, + owner: { connect: { id: owner.id } }, + ...(ownerProfile ? { profile: { connect: { id: ownerProfile.id } } } : {}), + users: { connect: hosts.map((h) => ({ id: h.id })) }, + hosts: { + create: hosts.map((h) => ({ + userId: h.id, + isFixed: false, + })), + }, + }, + }); + + await prisma.hostLocation.create({ + data: { + userId: owner.id, + eventTypeId: eventType.id, + type: "integrations:daily", + }, + }); + + await prisma.hostLocation.create({ + data: { + userId: member0.id, + eventTypeId: eventType.id, + type: "link", + link: "https://example.com/meet", + }, + }); + + await prisma.hostLocation.create({ + data: { + userId: member2.id, + eventTypeId: eventType.id, + type: "userPhone", + phoneNumber: "+1234567890", + }, + }); + + console.log( + `Seeded per-host locations in Acme Org for event "${eventType.slug}" (id=${eventType.id}): ` + + `owner1->Cal Video, member0->Link, member2->Phone` + ); +} + async function main() { await createUserAndEventType({ user: { @@ -1637,6 +1740,7 @@ async function main() { } await ensureAcmeOwnerHasApiKeySeeded(); + await seedPerHostLocationsInAcmeOrg(); } async function runSeed() {