@@ -922,7 +922,6 @@ async function getSkillIdsByNames (skills) {
922
922
// endpoint returns the partial matched skills
923
923
// we need to filter by exact match case insensitive
924
924
const filteredSkills = _ . filter ( result , tcSkill => _ . some ( skills , skill => _ . toLower ( skill ) === _ . toLower ( tcSkill . name ) ) )
925
- console . log ( filteredSkills )
926
925
const skillIds = _ . map ( filteredSkills , 'id' )
927
926
return skillIds
928
927
}
@@ -1018,41 +1017,33 @@ async function createTeam (currentUser, data) {
1018
1017
const projectRequestBody = {
1019
1018
name : data . teamName ,
1020
1019
description : data . teamDescription ,
1021
- type : 'app_dev ' ,
1020
+ type : 'talent-as-a-service ' ,
1022
1021
details : {
1023
1022
positions : data . positions
1024
1023
}
1025
1024
}
1026
1025
// 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 )
1034
1027
// create jobs for the given positions.
1035
1028
await Promise . all ( _ . map ( data . positions , async position => {
1036
1029
const roleSearchRequest = roleSearchRequests [ position . roleSearchRequestId ]
1037
1030
const job = {
1038
1031
projectId : project . id ,
1039
1032
title : position . roleName ,
1040
1033
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
1046
1040
}
1047
1041
if ( position . startMonth ) {
1048
1042
job . startDate = position . startMonth
1049
1043
}
1050
1044
if ( position . durationWeeks ) {
1051
1045
job . duration = position . durationWeeks
1052
1046
}
1053
- if ( roleSearchRequest . roleId ) {
1054
- job . roleIds = [ roleSearchRequest . roleId ]
1055
- }
1056
1047
await JobService . createJob ( currentUser , job )
1057
1048
} ) )
1058
1049
return { projectId : project . id }
@@ -1070,7 +1061,10 @@ createTeam.schema = Joi.object()
1070
1061
roleSearchRequestId : Joi . string ( ) . uuid ( ) . required ( ) ,
1071
1062
numberOfResources : Joi . number ( ) . integer ( ) . min ( 1 ) . required ( ) ,
1072
1063
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 ( )
1074
1068
} ) . required ( )
1075
1069
) . required ( )
1076
1070
} ) . required ( )
@@ -1088,19 +1082,23 @@ async function _validateRoleSearchRequests (roleSearchRequestIds) {
1088
1082
const roleSearchRequest = await RoleSearchRequest . findById ( roleSearchRequestId )
1089
1083
// store the found roleSearchRequest to avoid unnecessary DB calls
1090
1084
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` )
1094
1088
}
1089
+ const role = await Role . findById ( roleSearchRequest . roleId )
1095
1090
// if roleSearchRequest doesn't have skills, we have to get skills through role
1096
1091
if ( ! roleSearchRequest . skills ) {
1097
- const role = await Role . findById ( roleSearchRequest . roleId )
1098
1092
if ( ! role . listOfSkills ) {
1099
1093
throw new errors . ConflictError ( `role: ${ role . id } must have skills` )
1100
1094
}
1101
- // store the found skills
1095
+ // store role's skills
1102
1096
roleSearchRequests [ roleSearchRequestId ] . skills = await getSkillIdsByNames ( role . listOfSkills )
1103
1097
}
1098
+ if ( ! roleSearchRequest . jobDescription ) {
1099
+ roleSearchRequests [ roleSearchRequestId ] . jobDescription = role . description
1100
+ }
1101
+ roleSearchRequests [ roleSearchRequestId ] . resourceType = role . name
1104
1102
} ) )
1105
1103
return roleSearchRequests
1106
1104
}
0 commit comments