Skip to content

Commit e27ed47

Browse files
authored
[PROD] TaaS Release 1.0 (#613)
Changes Supporting TaaS Release 1.0
1 parent df3835e commit e27ed47

File tree

2 files changed

+35
-42
lines changed

2 files changed

+35
-42
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ workflows:
152152
- UnitTests
153153
filters:
154154
branches:
155-
only: ['develop']
155+
only: ['develop', 'connect-performance-testing']
156156
- deployProd:
157157
context : org-global
158158
requires:

src/events/projects/index.js

Lines changed: 34 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import Joi from 'joi';
66
import Promise from 'bluebird';
77
import config from 'config';
88
import axios from 'axios';
9-
import moment from 'moment';
109
import util from '../../util';
1110
import models from '../../models';
1211
import { createPhaseTopic } from '../projectPhases';
@@ -175,7 +174,6 @@ async function projectCreatedKafkaHandler(app, topic, payload) {
175174
if (result.error) {
176175
throw new Error(result.error);
177176
}
178-
179177
const project = payload;
180178

181179
if (project.phases && project.phases.length > 0) {
@@ -187,46 +185,41 @@ async function projectCreatedKafkaHandler(app, topic, payload) {
187185
await Promise.all(topicPromises);
188186
app.logger.debug('Topics for phases are successfully created.');
189187
}
190-
// TODO: temporary disable this feature, until we release TaaS APP
191-
if (false === true && project.type === 'talent-as-a-service') {
192-
const specialists = _.get(project, 'details.taasDefinition.specialists');
193-
if (!specialists || !specialists.length) {
194-
app.logger.debug(`no specialists found in the project ${project.id}`);
195-
return;
188+
try {
189+
if (project.type === 'talent-as-a-service') {
190+
const jobs = _.get(project, 'details.taasDefinition.taasJobs');
191+
if (!jobs || !jobs.length) {
192+
app.logger.debug(`no jobs found in the project id: ${project.id}`);
193+
return;
194+
}
195+
app.logger.debug(`${jobs.length} jobs found in the project id: ${project.id}`);
196+
await Promise.all(
197+
_.map(
198+
jobs,
199+
(job) => {
200+
// make sure that skills would be unique in the list and only include ones with 'skillId' (actually they all suppose to be with skillId)
201+
const skills = _.chain(job.skills).map('skillId').uniq().compact()
202+
.value();
203+
return createTaasJob({
204+
projectId: project.id,
205+
title: job.title,
206+
description: job.description,
207+
skills,
208+
numPositions: Number(job.people),
209+
resourceType: _.get(job, 'role.value', ''),
210+
rateType: 'weekly', // hardcode for now
211+
workload: _.get(job, 'workLoad.title', '').toLowerCase(),
212+
}).then((createdJob) => {
213+
app.logger.debug(`jobId: ${createdJob.id} job created with title "${createdJob.title}"`);
214+
}).catch((err) => {
215+
app.logger.error(`Unable to create job with title "${job.title}": ${err.message}`);
216+
});
217+
},
218+
),
219+
);
196220
}
197-
const targetSpecialists = _.filter(specialists, specialist => Number(specialist.people) > 0); // must be at least one people
198-
await Promise.all(
199-
_.map(
200-
targetSpecialists,
201-
(specialist) => {
202-
const startDate = new Date();
203-
const endDate = moment(startDate).add(Number(specialist.duration), 'M'); // the unit of duration is month
204-
// make sure that skills would be unique in the list
205-
const skills = _.uniq(
206-
// use both, required and additional skills for jobs
207-
specialist.skills.concat(specialist.additionalSkills)
208-
// only include skills with `skillId` and ignore custom skills in jobs
209-
.filter(skill => skill.skillId).map(skill => skill.skillId),
210-
);
211-
return createTaasJob({
212-
projectId: project.id,
213-
externalId: '0', // hardcode for now
214-
description: specialist.roleTitle,
215-
startDate,
216-
endDate,
217-
skills,
218-
numPositions: Number(specialist.people),
219-
resourceType: specialist.role,
220-
rateType: 'hourly', // hardcode for now
221-
workload: _.get(specialist, 'workLoad.title', '').toLowerCase(),
222-
}).then((job) => {
223-
app.logger.debug(`jobId: ${job.id} job created for roleTitle ${specialist.roleTitle}`);
224-
}).catch((err) => {
225-
app.logger.error(`Unable to create job for ${specialist.roleTitle}: ${err.message}`);
226-
});
227-
},
228-
),
229-
);
221+
} catch (error) {
222+
app.logger.error(`Error while creating TaaS jobs: ${error}`);
230223
}
231224
}
232225

0 commit comments

Comments
 (0)