Skip to content

Commit 5760a45

Browse files
authored
#4212-prettier
1 parent 7245828 commit 5760a45

2 files changed

Lines changed: 54 additions & 17 deletions

File tree

src/backend/src/prisma/factories/teams.factory.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Prisma, Team_Type } from '@prisma/client';
21
import { Faker } from '@faker-js/faker';
2+
import { Prisma, Team_Type } from '@prisma/client';
33
import type { FullUser } from '../context.js';
44

55
const SLACK_ID_RANDOM_LENGTH = 4;
@@ -44,7 +44,8 @@ export const seedTeamConfigs: SeedTeamConfig[] = [
4444
},
4545
{
4646
teamName: 'Battery',
47-
description: 'Designs and validates the battery pack and accumulator systems.',
47+
description:
48+
'Designs and validates the battery pack and accumulator systems.',
4849
teamTypeName: 'Electrical'
4950
},
5051
{
@@ -84,7 +85,8 @@ export const seedTeamConfigs: SeedTeamConfig[] = [
8485
},
8586
{
8687
teamName: 'Finance',
87-
description: 'Manages purchasing, reimbursements, budgeting, and sponsor funds.',
88+
description:
89+
'Manages purchasing, reimbursements, budgeting, and sponsor funds.',
8890
teamTypeName: 'Business',
8991
financeTeam: true
9092
},
@@ -115,14 +117,21 @@ export const seedTeamConfigs: SeedTeamConfig[] = [
115117
}
116118
];
117119

118-
const connectUsers = (users: FullUser[]) => users.map((user) => ({ userId: user.userId }));
120+
const connectUsers = (users: FullUser[]) =>
121+
users.map((user) => ({ userId: user.userId }));
119122

120123
const slackIdForTeam = (faker: Faker, teamName: string): string => {
121124
const slug = teamName.toLowerCase().replaceAll(' ', '-').replaceAll('/', '-');
122-
return `seed-${slug}-${faker.string.alphanumeric(SLACK_ID_RANDOM_LENGTH).toLowerCase()}`;
125+
126+
return `seed-${slug}-${faker.string
127+
.alphanumeric(SLACK_ID_RANDOM_LENGTH)
128+
.toLowerCase()}`;
123129
};
124130

125-
const findTeamType = (teamTypesByName: Record<string, Team_Type>, teamTypeName: string): Team_Type => {
131+
const findTeamType = (
132+
teamTypesByName: Record<string, Team_Type>,
133+
teamTypeName: string
134+
): Team_Type => {
126135
const teamType = teamTypesByName[teamTypeName];
127136

128137
if (!teamType) {

src/backend/src/prisma/seed/team.process.ts

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
import { Team, Team_Type } from '@prisma/client';
2-
import { ConfigDataOutput, ConfigDataProcess } from './config-data.process.js';
3-
import { OrganizationOutput, OrganizationProcess } from './organization.process.js';
2+
import {
3+
ConfigDataOutput,
4+
ConfigDataProcess
5+
} from './config-data.process.js';
6+
import {
7+
OrganizationOutput,
8+
OrganizationProcess
9+
} from './organization.process.js';
410
import { UsersOutput, UsersProcess } from './user.process.js';
5-
import { seedTeamConfigs, teamCreateInput } from '../factories/teams.factory.js';
11+
import {
12+
seedTeamConfigs,
13+
teamCreateInput
14+
} from '../factories/teams.factory.js';
615
import { SeedProcess } from '../processes/seed-process.js';
716

817
const EXPECTED_TEAM_COUNT = 20;
@@ -24,15 +33,29 @@ export class TeamProcess extends SeedProcess<TeamInput, TeamOutput> {
2433
return [OrganizationProcess, UsersProcess, ConfigDataProcess];
2534
}
2635

27-
async run({ organization, admins, heads, leadership, members, teamTypes }: TeamInput): Promise<TeamOutput> {
36+
async run({
37+
organization,
38+
admins,
39+
heads,
40+
leadership,
41+
members,
42+
teamTypes
43+
}: TeamInput): Promise<TeamOutput> {
2844
if (seedTeamConfigs.length !== EXPECTED_TEAM_COUNT) {
2945
throw new Error(
3046
`TeamProcess expected ${EXPECTED_TEAM_COUNT} teams but found ${seedTeamConfigs.length}.`
3147
);
3248
}
3349

34-
if (admins.length === 0 || heads.length === 0 || leadership.length === 0 || members.length === 0) {
35-
throw new Error('TeamProcess requires admins, heads, leadership, and members to create teams.');
50+
if (
51+
admins.length === 0 ||
52+
heads.length === 0 ||
53+
leadership.length === 0 ||
54+
members.length === 0
55+
) {
56+
throw new Error(
57+
'TeamProcess requires admins, heads, leadership, and members to create teams.'
58+
);
3659
}
3760

3861
const teamNames = seedTeamConfigs.map((team) => team.teamName);
@@ -41,10 +64,13 @@ export class TeamProcess extends SeedProcess<TeamInput, TeamOutput> {
4164
throw new Error('TeamProcess cannot generate duplicate team names.');
4265
}
4366

44-
const teamTypesByName = teamTypes.reduce<Record<string, Team_Type>>((acc, teamType) => {
45-
acc[teamType.name] = teamType;
46-
return acc;
47-
}, {});
67+
const teamTypesByName = teamTypes.reduce<Record<string, Team_Type>>(
68+
(acc, teamType) => {
69+
acc[teamType.name] = teamType;
70+
return acc;
71+
},
72+
{}
73+
);
4874

4975
const possibleHeads = [...heads, ...admins, ...leadership];
5076
const possibleLeads = [...leadership, ...heads, ...admins];
@@ -57,7 +83,9 @@ export class TeamProcess extends SeedProcess<TeamInput, TeamOutput> {
5783
throw new Error('TeamProcess could not find a head for a team.');
5884
}
5985

60-
const leadPool = possibleLeads.filter((user) => user.userId !== head.userId);
86+
const leadPool = possibleLeads.filter(
87+
(user) => user.userId !== head.userId
88+
);
6189

6290
const leads = this.faker.helpers.arrayElements(
6391
leadPool,

0 commit comments

Comments
 (0)