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 <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>
This commit is contained in:
co-authored by
hariom@cal.com
Udit Takkar
Devin AI
Udit Takkar
parent
5242e419d9
commit
17af50bbdc
+104
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user