11import { Team , Team_Type } from '@prisma/client' ;
2- import {
3- ConfigDataOutput ,
4- ConfigDataProcess
5- } from './config-data.process.js' ;
6- import {
7- OrganizationOutput ,
8- OrganizationProcess
9- } from './organization.process.js' ;
2+ import { ConfigDataOutput , ConfigDataProcess } from './config-data.process.js' ;
3+ import { OrganizationOutput , OrganizationProcess } from './organization.process.js' ;
104import { UsersOutput , UsersProcess } from './user.process.js' ;
11- import {
12- seedTeamConfigs ,
13- teamCreateInput
14- } from '../factories/teams.factory.js' ;
5+ import { seedTeamConfigs , teamCreateInput } from '../factories/teams.factory.js' ;
156import { SeedProcess } from '../processes/seed-process.js' ;
167
178const EXPECTED_TEAM_COUNT = 20 ;
@@ -33,29 +24,13 @@ export class TeamProcess extends SeedProcess<TeamInput, TeamOutput> {
3324 return [ OrganizationProcess , UsersProcess , ConfigDataProcess ] ;
3425 }
3526
36- async run ( {
37- organization,
38- admins,
39- heads,
40- leadership,
41- members,
42- teamTypes
43- } : TeamInput ) : Promise < TeamOutput > {
27+ async run ( { organization, admins, heads, leadership, members, teamTypes } : TeamInput ) : Promise < TeamOutput > {
4428 if ( seedTeamConfigs . length !== EXPECTED_TEAM_COUNT ) {
45- throw new Error (
46- `TeamProcess expected ${ EXPECTED_TEAM_COUNT } teams but found ${ seedTeamConfigs . length } .`
47- ) ;
29+ throw new Error ( `TeamProcess expected ${ EXPECTED_TEAM_COUNT } teams but found ${ seedTeamConfigs . length } .` ) ;
4830 }
4931
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- ) ;
32+ if ( admins . length === 0 || heads . length === 0 || leadership . length === 0 || members . length === 0 ) {
33+ throw new Error ( 'TeamProcess requires admins, heads, leadership, and members to create teams.' ) ;
5934 }
6035
6136 const teamNames = seedTeamConfigs . map ( ( team ) => team . teamName ) ;
@@ -64,13 +39,10 @@ export class TeamProcess extends SeedProcess<TeamInput, TeamOutput> {
6439 throw new Error ( 'TeamProcess cannot generate duplicate team names.' ) ;
6540 }
6641
67- const teamTypesByName = teamTypes . reduce < Record < string , Team_Type > > (
68- ( acc , teamType ) => {
69- acc [ teamType . name ] = teamType ;
70- return acc ;
71- } ,
72- { }
73- ) ;
42+ const teamTypesByName = teamTypes . reduce < Record < string , Team_Type > > ( ( acc , teamType ) => {
43+ acc [ teamType . name ] = teamType ;
44+ return acc ;
45+ } , { } ) ;
7446
7547 const possibleHeads = [ ...heads , ...admins , ...leadership ] ;
7648 const possibleLeads = [ ...leadership , ...heads , ...admins ] ;
@@ -83,9 +55,7 @@ export class TeamProcess extends SeedProcess<TeamInput, TeamOutput> {
8355 throw new Error ( 'TeamProcess could not find a head for a team.' ) ;
8456 }
8557
86- const leadPool = possibleLeads . filter (
87- ( user ) => user . userId !== head . userId
88- ) ;
58+ const leadPool = possibleLeads . filter ( ( user ) => user . userId !== head . userId ) ;
8959
9060 const leads = this . faker . helpers . arrayElements (
9161 leadPool ,
@@ -104,15 +74,7 @@ export class TeamProcess extends SeedProcess<TeamInput, TeamOutput> {
10474 ) ;
10575
10676 return this . prisma . team . create ( {
107- data : teamCreateInput (
108- this . faker ,
109- organization . organizationId ,
110- head ,
111- leads ,
112- teamMembers ,
113- teamTypesByName ,
114- config
115- )
77+ data : teamCreateInput ( this . faker , organization . organizationId , head , leads , teamMembers , teamTypesByName , config )
11678 } ) ;
11779 } )
11880 ) ;
@@ -130,4 +92,4 @@ export class TeamProcess extends SeedProcess<TeamInput, TeamOutput> {
13092
13193 return { teams, financeTeam, teamsByName } ;
13294 }
133- }
95+ }
0 commit comments