@@ -918,7 +918,6 @@ async function getSkillIdsByNames (skills) {
918
918
// endpoint returns the partial matched skills
919
919
// we need to filter by exact match case insensitive
920
920
const filteredSkills = _ . filter ( result , tcSkill => _ . some ( skills , skill => _ . toLower ( skill ) === _ . toLower ( tcSkill . name ) ) )
921
- console . log ( filteredSkills )
922
921
const skillIds = _ . map ( filteredSkills , 'id' )
923
922
return skillIds
924
923
}
@@ -1014,41 +1013,33 @@ async function createTeam (currentUser, data) {
1014
1013
const projectRequestBody = {
1015
1014
name : data . teamName ,
1016
1015
description : data . teamDescription ,
1017
- type : 'app_dev ' ,
1016
+ type : 'talent-as-a-service ' ,
1018
1017
details : {
1019
1018
positions : data . positions
1020
1019
}
1021
1020
}
1022
1021
// create project with given data
1023
- const project = await helper . createProject ( projectRequestBody )
1024
- // we created the project with m2m token
1025
- // so we have to add the current user as a member to the project
1026
- // the role of the user in the project will be determined by user's current roles.
1027
- if ( ! currentUser . isMachine ) {
1028
- await helper . createProjectMember ( project . id , { userId : currentUser . userId } )
1029
- }
1022
+ const project = await helper . createProject ( currentUser , projectRequestBody )
1030
1023
// create jobs for the given positions.
1031
1024
await Promise . all ( _ . map ( data . positions , async position => {
1032
1025
const roleSearchRequest = roleSearchRequests [ position . roleSearchRequestId ]
1033
1026
const job = {
1034
1027
projectId : project . id ,
1035
1028
title : position . roleName ,
1036
1029
numPositions : position . numberOfResources ,
1037
- rateType : 'weekly' ,
1038
- skills : roleSearchRequest . skills
1039
- }
1040
- if ( roleSearchRequest . jobDescription ) {
1041
- job . description = roleSearchRequest . jobDescription
1030
+ rateType : position . rateType ,
1031
+ workload : position . workload ,
1032
+ skills : roleSearchRequest . skills ,
1033
+ description : roleSearchRequest . jobDescription ,
1034
+ roleIds : [ roleSearchRequest . roleId ] ,
1035
+ resourceType : roleSearchRequest . resourceType
1042
1036
}
1043
1037
if ( position . startMonth ) {
1044
1038
job . startDate = position . startMonth
1045
1039
}
1046
1040
if ( position . durationWeeks ) {
1047
1041
job . duration = position . durationWeeks
1048
1042
}
1049
- if ( roleSearchRequest . roleId ) {
1050
- job . roleIds = [ roleSearchRequest . roleId ]
1051
- }
1052
1043
await JobService . createJob ( currentUser , job )
1053
1044
} ) )
1054
1045
return { projectId : project . id }
@@ -1066,7 +1057,10 @@ createTeam.schema = Joi.object()
1066
1057
roleSearchRequestId : Joi . string ( ) . uuid ( ) . required ( ) ,
1067
1058
numberOfResources : Joi . number ( ) . integer ( ) . min ( 1 ) . required ( ) ,
1068
1059
durationWeeks : Joi . number ( ) . integer ( ) . min ( 1 ) ,
1069
- startMonth : Joi . date ( )
1060
+ startMonth : Joi . date ( ) ,
1061
+ rateType : Joi . rateType ( ) . default ( 'weekly' ) ,
1062
+ workload : Joi . workload ( ) . default ( 'full-time' ) ,
1063
+ resourceType : Joi . string ( )
1070
1064
} ) . required ( )
1071
1065
) . required ( )
1072
1066
} ) . required ( )
@@ -1084,19 +1078,23 @@ async function _validateRoleSearchRequests (roleSearchRequestIds) {
1084
1078
const roleSearchRequest = await RoleSearchRequest . findById ( roleSearchRequestId )
1085
1079
// store the found roleSearchRequest to avoid unnecessary DB calls
1086
1080
roleSearchRequests [ roleSearchRequestId ] = roleSearchRequest . toJSON ( )
1087
- // we can't create a job without skills
1088
- if ( ! roleSearchRequest . roleId && ! roleSearchRequest . skills ) {
1089
- throw new errors . ConflictError ( `roleSearchRequestId: ${ roleSearchRequestId } must have roleId or skills ` )
1081
+ // we can't create a job without a role
1082
+ if ( ! roleSearchRequest . roleId ) {
1083
+ throw new errors . ConflictError ( `roleSearchRequestId: ${ roleSearchRequestId } must have roleId` )
1090
1084
}
1085
+ const role = await Role . findById ( roleSearchRequest . roleId )
1091
1086
// if roleSearchRequest doesn't have skills, we have to get skills through role
1092
1087
if ( ! roleSearchRequest . skills ) {
1093
- const role = await Role . findById ( roleSearchRequest . roleId )
1094
1088
if ( ! role . listOfSkills ) {
1095
1089
throw new errors . ConflictError ( `role: ${ role . id } must have skills` )
1096
1090
}
1097
- // store the found skills
1091
+ // store role's skills
1098
1092
roleSearchRequests [ roleSearchRequestId ] . skills = await getSkillIdsByNames ( role . listOfSkills )
1099
1093
}
1094
+ if ( ! roleSearchRequest . jobDescription ) {
1095
+ roleSearchRequests [ roleSearchRequestId ] . jobDescription = role . description
1096
+ }
1097
+ roleSearchRequests [ roleSearchRequestId ] . resourceType = role . name
1100
1098
} ) )
1101
1099
return roleSearchRequests
1102
1100
}
0 commit comments