Skip to content

Commit f8e3b8c

Browse files
committed
fix: improvements to job creation
- use token from ENV variable instead of M2M until TaaS API supports M2M
1 parent 4116ef1 commit f8e3b8c

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/events/projects/index.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ const eClient = util.getElasticSearchClient();
2222
* @return {Object} the job created
2323
*/
2424
const createTaasJob = async (data) => {
25-
const token = await util.getM2MToken();
25+
// TODO uncomment when TaaS API supports M2M tokens
26+
// see https://github.com/topcoder-platform/taas-apis/issues/40
27+
// const token = await util.getM2MToken();
28+
const token = process.env.TAAS_API_TOKEN;
2629
const headers = {
2730
'Content-Type': 'application/json',
2831
Authorization: `Bearer ${token}`,
@@ -200,18 +203,21 @@ async function projectCreatedKafkaHandler(app, topic, payload) {
200203
(specialist) => {
201204
const startDate = new Date();
202205
const endDate = moment(startDate).add(Number(specialist.duration), 'M'); // the unit of duration is month
203-
const skills = specialist.skills.filter(skill => skill.id).map(skill => skill.id);
206+
// use both, required and additional skills for jobs
207+
const skills = specialist.skills.concat(specialist.additionalSkills)
208+
// only include skills with `id` and ignore custom skills in jobs
209+
.filter(skill => skill.id).map(skill => skill.id);
204210
return createTaasJob({
205211
projectId: project.id,
206-
externalId: _.get(project, 'external.id') || String(project.id),
212+
externalId: '0', // hardcode for now
207213
description: specialist.roleTitle,
208214
startDate,
209215
endDate,
210216
skills,
211217
numPositions: Number(specialist.people),
212218
resourceType: specialist.role,
213-
rateType: 'hourly',
214-
workload: specialist.workLoad.title.toLowerCase(),
219+
rateType: 'hourly', // hardcode for now
220+
workload: _.get(specialist, 'workLoad.title', '').toLowerCase(),
215221
}).then((job) => {
216222
app.logger.debug(`jobId: ${job.id} job created for roleTitle ${specialist.roleTitle}`);
217223
}).catch((err) => {

0 commit comments

Comments
 (0)