@@ -922,7 +922,6 @@ async function getSkillIdsByNames (skills) {
922922 // endpoint returns the partial matched skills
923923 // we need to filter by exact match case insensitive
924924 const filteredSkills = _ . filter ( result , tcSkill => _ . some ( skills , skill => _ . toLower ( skill ) === _ . toLower ( tcSkill . name ) ) )
925- console . log ( filteredSkills )
926925 const skillIds = _ . map ( filteredSkills , 'id' )
927926 return skillIds
928927}
@@ -1018,41 +1017,33 @@ async function createTeam (currentUser, data) {
10181017 const projectRequestBody = {
10191018 name : data . teamName ,
10201019 description : data . teamDescription ,
1021- type : 'app_dev ' ,
1020+ type : 'talent-as-a-service ' ,
10221021 details : {
10231022 positions : data . positions
10241023 }
10251024 }
10261025 // create project with given data
1027- const project = await helper . createProject ( projectRequestBody )
1028- // we created the project with m2m token
1029- // so we have to add the current user as a member to the project
1030- // the role of the user in the project will be determined by user's current roles.
1031- if ( ! currentUser . isMachine ) {
1032- await helper . createProjectMember ( project . id , { userId : currentUser . userId } )
1033- }
1026+ const project = await helper . createProject ( currentUser , projectRequestBody )
10341027 // create jobs for the given positions.
10351028 await Promise . all ( _ . map ( data . positions , async position => {
10361029 const roleSearchRequest = roleSearchRequests [ position . roleSearchRequestId ]
10371030 const job = {
10381031 projectId : project . id ,
10391032 title : position . roleName ,
10401033 numPositions : position . numberOfResources ,
1041- rateType : 'weekly' ,
1042- skills : roleSearchRequest . skills
1043- }
1044- if ( roleSearchRequest . jobDescription ) {
1045- job . description = roleSearchRequest . jobDescription
1034+ rateType : position . rateType ,
1035+ workload : position . workload ,
1036+ skills : roleSearchRequest . skills ,
1037+ description : roleSearchRequest . jobDescription ,
1038+ roleIds : [ roleSearchRequest . roleId ] ,
1039+ resourceType : roleSearchRequest . resourceType
10461040 }
10471041 if ( position . startMonth ) {
10481042 job . startDate = position . startMonth
10491043 }
10501044 if ( position . durationWeeks ) {
10511045 job . duration = position . durationWeeks
10521046 }
1053- if ( roleSearchRequest . roleId ) {
1054- job . roleIds = [ roleSearchRequest . roleId ]
1055- }
10561047 await JobService . createJob ( currentUser , job )
10571048 } ) )
10581049 return { projectId : project . id }
@@ -1070,7 +1061,10 @@ createTeam.schema = Joi.object()
10701061 roleSearchRequestId : Joi . string ( ) . uuid ( ) . required ( ) ,
10711062 numberOfResources : Joi . number ( ) . integer ( ) . min ( 1 ) . required ( ) ,
10721063 durationWeeks : Joi . number ( ) . integer ( ) . min ( 1 ) ,
1073- startMonth : Joi . date ( )
1064+ startMonth : Joi . date ( ) ,
1065+ rateType : Joi . rateType ( ) . default ( 'weekly' ) ,
1066+ workload : Joi . workload ( ) . default ( 'full-time' ) ,
1067+ resourceType : Joi . string ( )
10741068 } ) . required ( )
10751069 ) . required ( )
10761070 } ) . required ( )
@@ -1088,19 +1082,23 @@ async function _validateRoleSearchRequests (roleSearchRequestIds) {
10881082 const roleSearchRequest = await RoleSearchRequest . findById ( roleSearchRequestId )
10891083 // store the found roleSearchRequest to avoid unnecessary DB calls
10901084 roleSearchRequests [ roleSearchRequestId ] = roleSearchRequest . toJSON ( )
1091- // we can't create a job without skills
1092- if ( ! roleSearchRequest . roleId && ! roleSearchRequest . skills ) {
1093- throw new errors . ConflictError ( `roleSearchRequestId: ${ roleSearchRequestId } must have roleId or skills ` )
1085+ // we can't create a job without a role
1086+ if ( ! roleSearchRequest . roleId ) {
1087+ throw new errors . ConflictError ( `roleSearchRequestId: ${ roleSearchRequestId } must have roleId` )
10941088 }
1089+ const role = await Role . findById ( roleSearchRequest . roleId )
10951090 // if roleSearchRequest doesn't have skills, we have to get skills through role
10961091 if ( ! roleSearchRequest . skills ) {
1097- const role = await Role . findById ( roleSearchRequest . roleId )
10981092 if ( ! role . listOfSkills ) {
10991093 throw new errors . ConflictError ( `role: ${ role . id } must have skills` )
11001094 }
1101- // store the found skills
1095+ // store role's skills
11021096 roleSearchRequests [ roleSearchRequestId ] . skills = await getSkillIdsByNames ( role . listOfSkills )
11031097 }
1098+ if ( ! roleSearchRequest . jobDescription ) {
1099+ roleSearchRequests [ roleSearchRequestId ] . jobDescription = role . description
1100+ }
1101+ roleSearchRequests [ roleSearchRequestId ] . resourceType = role . name
11041102 } ) )
11051103 return roleSearchRequests
11061104}
0 commit comments