Skip to content

Commit 8035016

Browse files
committed
feat: polish release - 2
* Accept `hoursPerWeek` for jobs, when creating a team. * Fix `getSkillIdsByNames` to return ids in the exact same order of names. * Include skill ids in `getSkillsByJobDescription` response Addresses topcoder-archive/topcoder-platform-taas-app#400, topcoder-archive/topcoder-platform-taas-app#407
1 parent 1c1ab57 commit 8035016

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

docs/swagger.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -3655,6 +3655,9 @@ components:
36553655
schemas:
36563656
SkillItem:
36573657
properties:
3658+
id:
3659+
type: string
3660+
format: uuid
36583661
tag:
36593662
type: string
36603663
example: "Java"
@@ -5440,6 +5443,11 @@ components:
54405443
example: 10
54415444
minimum: 1
54425445
description: "The number of needed resources"
5446+
hoursPerWeek:
5447+
type: integer
5448+
example: 40
5449+
minimum: 1
5450+
description: "The amount of working hours per week"
54435451
durationWeeks:
54445452
type: integer
54455453
example: 5

src/services/TeamService.js

+10-6
Original file line numberDiff line numberDiff line change
@@ -874,10 +874,12 @@ async function getSkillsByJobDescription (data) {
874874
})
875875
})
876876
foundSkills = _.uniq(foundSkills)
877+
const skillIds = await getSkillIdsByNames(foundSkills)
877878
// apply desired template
878-
_.each(foundSkills, skill => {
879+
_.each(foundSkills, (skillTag, idx) => {
879880
result.push({
880-
tag: skill,
881+
id: skillIds[idx],
882+
tag: skillTag,
881883
type: 'taas_skill',
882884
source: 'taas-jd-parser'
883885
})
@@ -933,12 +935,12 @@ getSkillNamesByIds.schema = Joi.object()
933935
* @returns {Array<string>} the array of skill ids
934936
*/
935937
async function getSkillIdsByNames (skills) {
936-
const result = await helper.getAllTopcoderSkills({ name: _.join(skills, ',') })
938+
const tcSkills = await helper.getAllTopcoderSkills({ name: _.join(skills, ',') })
937939
// endpoint returns the partial matched skills
938940
// we need to filter by exact match case insensitive
939-
const filteredSkills = _.filter(result, tcSkill => _.some(skills, skill => _.toLower(skill) === _.toLower(tcSkill.name)))
940-
const skillIds = _.map(filteredSkills, 'id')
941-
return skillIds
941+
// const filteredSkills = _.filter(result, tcSkill => _.some(skills, skill => _.toLower(skill) === _.toLower(tcSkill.name)))
942+
const matchedSkills = _.map(skills, skillTag => tcSkills.find(tcSkill => _.toLower(skillTag) === _.toLower(tcSkill.name)))
943+
return _.map(matchedSkills, 'id')
942944
}
943945

944946
getSkillIdsByNames.schema = Joi.object()
@@ -1051,6 +1053,7 @@ async function createTeam (currentUser, data) {
10511053
numPositions: position.numberOfResources,
10521054
rateType: position.rateType,
10531055
workload: position.workload,
1056+
hoursPerWeek: position.hoursPerWeek,
10541057
skills: roleSearchRequest.skills,
10551058
description: roleSearchRequest.jobDescription,
10561059
roleIds: [roleSearchRequest.roleId],
@@ -1083,6 +1086,7 @@ createTeam.schema = Joi.object()
10831086
startMonth: Joi.date(),
10841087
rateType: Joi.rateType().default('weekly'),
10851088
workload: Joi.workload().default('full-time'),
1089+
hoursPerWeek: Joi.number().integer().positive(),
10861090
resourceType: Joi.string()
10871091
}).required()
10881092
).required()

0 commit comments

Comments
 (0)