Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

🌱 Update seed data

Luke Vella61c415faeed0
diff --git a/packages/database/prisma/seed/polls.ts b/packages/database/prisma/seed/polls.ts
index bb198bc9a..86460ea31 100644
--- a/packages/database/prisma/seed/polls.ts
+++ b/packages/database/prisma/seed/polls.ts
@@ -17,6 +17,17 @@ function generateTitle() {
() => `${faker.name.jobType()} Interview`,
() => `${faker.commerce.productAdjective()} Product Review`,
() => `Team ${faker.word.verb()} Day`,
+ // More team-focused titles
+ () => "Weekly All-Hands Meeting",
+ () => "Sprint Planning Session",
+ () => "Product Roadmap Discussion",
+ () => "Team Building Event",
+ () => "Client Presentation Review",
+ () => "Budget Planning Meeting",
+ () => "New Feature Brainstorming",
+ () => "Performance Review Check-in",
+ () => "Company Town Hall",
+ () => "Training Workshop Session",
];
return faker.helpers.arrayElement(titleTemplates)();
@@ -35,12 +46,88 @@ function generateDescription() {
"A brainstorming session for the new campaign. All creative minds are welcome!",
"Review of the last sprint and planning for the next one. Let's ensure we're on track.",
"An open forum for team members to share updates and challenges. Everyone is encouraged to speak up.",
+ // More team-focused descriptions
+ "Company-wide meeting to discuss strategic initiatives and answer questions from all departments.",
+ "Planning session for the next sprint cycle. We'll review backlog items and set priorities.",
+ "Review our product roadmap and get alignment on upcoming features and releases.",
+ "Fun team activity to improve collaboration and build stronger relationships across departments.",
+ "Preparation meeting for the upcoming client presentation. Let's align on key messaging.",
+ "Annual budget planning session to discuss resource allocation for the next fiscal year.",
+ "Creative session to generate ideas for the new product feature. All perspectives welcome!",
+ "Regular one-on-one meetings to discuss performance, goals, and career development.",
+ "Quarterly company update covering financial performance, new hires, and strategic direction.",
+ "Hands-on workshop to develop new skills and improve team capabilities.",
];
// Randomly select a description
return faker.helpers.arrayElement(descriptions);
}
+async function addTeamParticipantsToPolls() {
+ console.info("Adding team members as participants to polls...");
+
+ // Get all team members
+ const teamMembers = await prisma.user.findMany({
+ where: {
+ id: {
+ in: ["team-owner", "team-admin", "team-member-1", "team-member-2", "team-member-3"]
+ }
+ }
+ });
+
+ // Get team space polls
+ const teamPolls = await prisma.poll.findMany({
+ where: {
+ spaceId: "team-space-1"
+ },
+ include: {
+ options: true,
+ participants: true
+ }
+ });
+
+ // Add team members as participants to some polls
+ for (const poll of teamPolls) {
+ // Skip if poll already has team participants
+ const existingTeamParticipants = poll.participants.filter(p =>
+ teamMembers.some(tm => tm.email === p.email)
+ );
+
+ if (existingTeamParticipants.length > 0) continue;
+
+ // Add 2-4 random team members as participants
+ const numParticipants = randInt(3, 2);
+ const selectedMembers = faker.helpers.arrayElements(teamMembers, numParticipants);
+
+ for (const member of selectedMembers) {
+ const participant = await prisma.participant.create({
+ data: {
+ pollId: poll.id,
+ name: member.name,
+ email: member.email,
+ }
+ });
+
+ // Add votes for this participant
+ const voteData = poll.options.map((option) => ({
+ id: faker.random.alpha(10),
+ optionId: option.id,
+ participantId: participant.id,
+ pollId: poll.id,
+ type: faker.helpers.arrayElement(["yes", "no", "ifNeedBe"]) as VoteType,
+ }));
+
+ if (voteData.length > 0) {
+ await prisma.vote.createMany({
+ data: voteData,
+ });
+ }
+ }
+ }
+
+ console.info(`βœ“ Added team participation to polls`);
+}
+
async function createPollForUser({
userId,
spaceId,
@@ -117,8 +204,85 @@ async function createPollForUser({
return poll;
}
+async function seedTeamPolls() {
+ console.info("Seeding team polls...");
+ const teamSpace = await prisma.space.findUnique({
+ where: { id: "team-space-1" },
+ include: {
+ members: {
+ include: { user: true },
+ },
+ },
+ });
+
+ if (!teamSpace) {
+ console.warn("Team space not found, skipping team polls");
+ return;
+ }
+
+ // Create polls from different team members
+ const teamMemberIds = teamSpace.members.map((member) => member.userId);
+
+ // Create more realistic team polls
+ const teamPollPromises = [
+ // Owner creates strategic polls
+ ...Array.from({ length: 8 }).map(() =>
+ createPollForUser({
+ userId: "team-owner",
+ spaceId: teamSpace.id
+ }),
+ ),
+ // Admin creates operational polls
+ ...Array.from({ length: 6 }).map(() =>
+ createPollForUser({
+ userId: "team-admin",
+ spaceId: teamSpace.id
+ }),
+ ),
+ // Members create various polls
+ ...Array.from({ length: 4 }).map(() =>
+ createPollForUser({
+ userId: "team-member-1",
+ spaceId: teamSpace.id
+ }),
+ ),
+ ...Array.from({ length: 3 }).map(() =>
+ createPollForUser({
+ userId: "team-member-2",
+ spaceId: teamSpace.id
+ }),
+ ),
+ ...Array.from({ length: 2 }).map(() =>
+ createPollForUser({
+ userId: "team-member-3",
+ spaceId: teamSpace.id
+ }),
+ ),
+ ];
+
+ await Promise.all(teamPollPromises);
+ console.info(`βœ“ Seeded ${teamPollPromises.length} team polls`);
+
+ // Add cross-team participation
+ await addTeamParticipantsToPolls();
+}
+
export async function seedPolls(userId: string) {
- console.info("Seeding polls...");
+ console.info(`Seeding polls for user ${userId}...`);
+
+ // Handle team space separately
+ if (userId === "team-owner") {
+ await seedTeamPolls();
+ return;
+ }
+
+ // Skip other team members as they're handled in team polling
+ const teamMemberIds = ["team-admin", "team-member-1", "team-member-2", "team-member-3"];
+ if (teamMemberIds.includes(userId)) {
+ console.info(`Skipping individual polls for team member ${userId} (included in team polls)`);
+ return;
+ }
+
const space = await prisma.space.findFirst({
where: {
ownerId: userId,
diff --git a/packages/database/prisma/seed/scheduled-events.ts b/packages/database/prisma/seed/scheduled-events.ts
index 899e3176e..cce642a75 100644
--- a/packages/database/prisma/seed/scheduled-events.ts
+++ b/packages/database/prisma/seed/scheduled-events.ts
@@ -142,8 +142,79 @@ async function createScheduledEventForUser({
});
}
+async function seedTeamEvents() {
+ console.info("Seeding team scheduled events...");
+ const teamSpace = await prisma.space.findUnique({
+ where: { id: "team-space-1" },
+ include: {
+ members: {
+ include: { user: true },
+ },
+ },
+ });
+
+ if (!teamSpace) {
+ console.warn("Team space not found, skipping team events");
+ return;
+ }
+
+ // Create events from different team members
+ const teamEventPromises = [
+ // Owner creates important company events
+ ...Array.from({ length: 12 }).map(() =>
+ createScheduledEventForUser({
+ userId: "team-owner",
+ spaceId: teamSpace.id
+ }),
+ ),
+ // Admin creates operational events
+ ...Array.from({ length: 10 }).map(() =>
+ createScheduledEventForUser({
+ userId: "team-admin",
+ spaceId: teamSpace.id
+ }),
+ ),
+ // Members create department/project events
+ ...Array.from({ length: 6 }).map(() =>
+ createScheduledEventForUser({
+ userId: "team-member-1",
+ spaceId: teamSpace.id
+ }),
+ ),
+ ...Array.from({ length: 5 }).map(() =>
+ createScheduledEventForUser({
+ userId: "team-member-2",
+ spaceId: teamSpace.id
+ }),
+ ),
+ ...Array.from({ length: 4 }).map(() =>
+ createScheduledEventForUser({
+ userId: "team-member-3",
+ spaceId: teamSpace.id
+ }),
+ ),
+ ];
+
+ await Promise.all(teamEventPromises);
+ console.info(`βœ“ Seeded ${teamEventPromises.length} team events`);
+}
+
export async function seedScheduledEvents(userId: string) {
- console.info("Seeding scheduled events...");
+ console.info(`Seeding scheduled events for user ${userId}...`);
+
+ // Handle team space separately
+ if (userId === "team-owner") {
+ await seedTeamEvents();
+ return;
+ }
+
+ // Skip other team members as they're handled in team events
+ const teamMemberIds = ["team-admin", "team-member-1", "team-member-2", "team-member-3"];
+ if (teamMemberIds.includes(userId)) {
+ console.info(`Skipping individual events for team member ${userId} (included in team events)`);
+ return;
+ }
+
const space = await prisma.space.findFirst({
where: {
ownerId: userId,
diff --git a/packages/database/prisma/seed/users.ts b/packages/database/prisma/seed/users.ts
index 8db90764c..f97aaf298 100644
--- a/packages/database/prisma/seed/users.ts
+++ b/packages/database/prisma/seed/users.ts
@@ -64,6 +64,131 @@ async function createUser({
return user;
}
+async function createTeamSpace() {
+ console.info("Creating team space...");
+
+ // Create team owner first
+ const teamOwner = await prisma.user.create({
+ data: {
+ id: "team-owner",
+ name: "Sarah Johnson",
+ email: "[email protected]",
+ timeZone: "America/New_York",
+ },
+ });
+
+ // Then create the team space
+ const teamSpace = await prisma.space.create({
+ data: {
+ id: "team-space-1",
+ name: "Acme Corp Team",
+ ownerId: teamOwner.id,
+ },
+ });
+
+ const teamMembers = await Promise.all([
+ prisma.user.create({
+ data: {
+ id: "team-admin",
+ name: "Michael Chen",
+ email: "[email protected]",
+ timeZone: "America/Los_Angeles",
+ },
+ }),
+ prisma.user.create({
+ data: {
+ id: "team-member-1",
+ name: "Emily Rodriguez",
+ email: "[email protected]",
+ timeZone: "America/Chicago",
+ },
+ }),
+ prisma.user.create({
+ data: {
+ id: "team-member-2",
+ name: "James Wilson",
+ email: "[email protected]",
+ timeZone: "Europe/London",
+ },
+ }),
+ prisma.user.create({
+ data: {
+ id: "team-member-3",
+ name: "Lisa Park",
+ email: "[email protected]",
+ timeZone: "Asia/Tokyo",
+ },
+ }),
+ ]);
+
+ // Add team members to space with different roles
+ await Promise.all([
+ prisma.spaceMember.create({
+ data: {
+ spaceId: teamSpace.id,
+ userId: teamOwner.id,
+ role: "ADMIN",
+ lastSelectedAt: new Date(),
+ },
+ }),
+ prisma.spaceMember.create({
+ data: {
+ spaceId: teamSpace.id,
+ userId: "team-admin",
+ role: "ADMIN",
+ lastSelectedAt: new Date(),
+ },
+ }),
+ prisma.spaceMember.create({
+ data: {
+ spaceId: teamSpace.id,
+ userId: "team-member-1",
+ role: "MEMBER",
+ lastSelectedAt: new Date(),
+ },
+ }),
+ prisma.spaceMember.create({
+ data: {
+ spaceId: teamSpace.id,
+ userId: "team-member-2",
+ role: "MEMBER",
+ lastSelectedAt: new Date(),
+ },
+ }),
+ prisma.spaceMember.create({
+ data: {
+ spaceId: teamSpace.id,
+ userId: "team-member-3",
+ role: "MEMBER",
+ lastSelectedAt: new Date(),
+ },
+ }),
+ ]);
+
+ // Add Pro subscription for the team space
+ await prisma.subscription.create({
+ data: {
+ id: "team-sub-1",
+ spaceId: teamSpace.id,
+ userId: teamOwner.id,
+ subscriptionItemId: "team-subitem-1",
+ quantity: 5, // Team of 5
+ active: true,
+ amount: 2800, // $28 for team plan
+ currency: "USD",
+ interval: "month",
+ periodStart: new Date(),
+ periodEnd: dayjs().add(1, "month").toDate(),
+ priceId: "price_team_monthly",
+ status: "active",
+ },
+ });
+
+ console.info(`βœ“ Seeded team space with ${[teamOwner, ...teamMembers].length} members`);
+
+ return [teamOwner, ...teamMembers];
+}
+
export async function seedUsers() {
console.info("Seeding users...");
const freeUser = await createUser({
@@ -90,8 +215,11 @@ export async function seedUsers() {
},
});
+ // Create team space with multiple members
+ const teamMembers = await createTeamSpace();
+
console.info(`βœ“ Seeded user ${freeUser.email}`);
console.info(`βœ“ Seeded user ${proUser.email}`);
- return [freeUser, proUser];
+ return [freeUser, proUser, ...teamMembers];
}