Skip to content

Commit 17af50b

Browse files
hariombalharaUdit-takkardevin-ai-integration[bot]
authored
feat: add per-host locations seed data in Acme Org for QA (calcom#27832)
* fix: host location option * feat: add per-host locations seed data for Round Robin event type Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com> * refactor: move per-host locations seed to Acme Org with dedicated event type Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com> * fix: check app existence before creating credentials in per-host location seed Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com> * refactor: remove credential-based app seeding, use simple location types instead Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com> --------- Co-authored-by: Udit Takkar <udit222001@gmail.com> 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>
1 parent 5242e41 commit 17af50b

1 file changed

Lines changed: 104 additions & 0 deletions

File tree

scripts/seed.ts

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,109 @@ async function ensureAcmeOwnerHasApiKeySeeded() {
693693
}
694694
}
695695

696+
async function seedPerHostLocationsInAcmeOrg() {
697+
const acmeOrg = await prisma.team.findFirst({
698+
where: { slug: "acme", parentId: null },
699+
select: { id: true },
700+
});
701+
if (!acmeOrg) {
702+
console.log("Acme org not found, skipping per-host location seeding.");
703+
return;
704+
}
705+
706+
const acmeTeam = await prisma.team.findFirst({
707+
where: { slug: "team1", parentId: acmeOrg.id },
708+
select: { id: true },
709+
});
710+
if (!acmeTeam) {
711+
console.log("Acme Team 1 not found, skipping per-host location seeding.");
712+
return;
713+
}
714+
715+
const existingEvent = await prisma.eventType.findFirst({
716+
where: { slug: "per-host-location-event", teamId: acmeTeam.id },
717+
});
718+
if (existingEvent) {
719+
console.log("Per-host location event already seeded in Acme, skipping.");
720+
return;
721+
}
722+
723+
const owner = await prisma.user.findFirst({
724+
where: { email: "owner1-acme@example.com" },
725+
select: { id: true },
726+
});
727+
const member0 = await prisma.user.findFirst({
728+
where: { email: "member0-acme@example.com" },
729+
select: { id: true },
730+
});
731+
const member2 = await prisma.user.findFirst({
732+
where: { email: "member2-acme@example.com" },
733+
select: { id: true },
734+
});
735+
if (!owner || !member0 || !member2) {
736+
console.log("Required Acme members not found, skipping per-host location seeding.");
737+
return;
738+
}
739+
740+
const hosts = [owner, member0, member2];
741+
742+
const ownerProfile = await prisma.profile.findFirst({
743+
where: { userId: owner.id, organizationId: acmeOrg.id },
744+
select: { id: true },
745+
});
746+
747+
const eventType = await prisma.eventType.create({
748+
data: {
749+
title: "Per Host Location Event",
750+
slug: "per-host-location-event",
751+
length: 30,
752+
schedulingType: SchedulingType.ROUND_ROBIN,
753+
enablePerHostLocations: true,
754+
team: { connect: { id: acmeTeam.id } },
755+
owner: { connect: { id: owner.id } },
756+
...(ownerProfile ? { profile: { connect: { id: ownerProfile.id } } } : {}),
757+
users: { connect: hosts.map((h) => ({ id: h.id })) },
758+
hosts: {
759+
create: hosts.map((h) => ({
760+
userId: h.id,
761+
isFixed: false,
762+
})),
763+
},
764+
},
765+
});
766+
767+
await prisma.hostLocation.create({
768+
data: {
769+
userId: owner.id,
770+
eventTypeId: eventType.id,
771+
type: "integrations:daily",
772+
},
773+
});
774+
775+
await prisma.hostLocation.create({
776+
data: {
777+
userId: member0.id,
778+
eventTypeId: eventType.id,
779+
type: "link",
780+
link: "https://example.com/meet",
781+
},
782+
});
783+
784+
await prisma.hostLocation.create({
785+
data: {
786+
userId: member2.id,
787+
eventTypeId: eventType.id,
788+
type: "userPhone",
789+
phoneNumber: "+1234567890",
790+
},
791+
});
792+
793+
console.log(
794+
`Seeded per-host locations in Acme Org for event "${eventType.slug}" (id=${eventType.id}): ` +
795+
`owner1->Cal Video, member0->Link, member2->Phone`
796+
);
797+
}
798+
696799
async function main() {
697800
await createUserAndEventType({
698801
user: {
@@ -1637,6 +1740,7 @@ async function main() {
16371740
}
16381741

16391742
await ensureAcmeOwnerHasApiKeySeeded();
1743+
await seedPerHostLocationsInAcmeOrg();
16401744
}
16411745

16421746
async function runSeed() {

0 commit comments

Comments
 (0)