@@ -5,7 +5,6 @@ import _ from 'lodash';
55import Joi from 'joi' ;
66import Promise from 'bluebird' ;
77import config from 'config' ;
8- import axios from 'axios' ;
98import util from '../../util' ;
109import models from '../../models' ;
1110import { createPhaseTopic } from '../projectPhases' ;
@@ -15,27 +14,6 @@ const ES_PROJECT_INDEX = config.get('elasticsearchConfig.indexName');
1514const ES_PROJECT_TYPE = config . get ( 'elasticsearchConfig.docType' ) ;
1615const eClient = util . getElasticSearchClient ( ) ;
1716
18- /**
19- * creates taas job
20- * @param {Object } data the job data
21- * @return {Object } the job created
22- */
23- const createTaasJob = async ( data ) => {
24- const token = await util . getM2MToken ( ) ;
25- const headers = {
26- 'Content-Type' : 'application/json' ,
27- Authorization : `Bearer ${ token } ` ,
28- } ;
29- const res = await axios
30- . post ( config . taasJobApiUrl , data , { headers } )
31- . catch ( ( err ) => {
32- const error = new Error ( ) ;
33- error . message = _ . get ( err , 'response.data.message' , error . message ) ;
34- throw error ;
35- } ) ;
36- return res . data ;
37- } ;
38-
3917/**
4018 * Payload for deprecated BUS events like `connect.notification.project.updated`.
4119 */
@@ -186,42 +164,6 @@ async function projectCreatedKafkaHandler(app, topic, payload) {
186164 await Promise . all ( topicPromises ) ;
187165 app . logger . debug ( 'Topics for phases are successfully created.' ) ;
188166 }
189- try {
190- if ( project . type === 'talent-as-a-service' ) {
191- const jobs = _ . get ( project , 'details.taasDefinition.taasJobs' ) ;
192- if ( ! jobs || ! jobs . length ) {
193- app . logger . debug ( `no jobs found in the project id: ${ project . id } ` ) ;
194- return ;
195- }
196- app . logger . debug ( `${ jobs . length } jobs found in the project id: ${ project . id } ` ) ;
197- await Promise . all (
198- _ . map (
199- jobs ,
200- ( job ) => {
201- // make sure that skills would be unique in the list and only include ones with 'skillId' (actually they all suppose to be with skillId)
202- const skills = _ . chain ( job . skills ) . map ( 'skillId' ) . uniq ( ) . compact ( )
203- . value ( ) ;
204- return createTaasJob ( {
205- projectId : project . id ,
206- title : job . title ,
207- description : job . description ,
208- skills,
209- numPositions : Number ( job . people ) ,
210- resourceType : _ . get ( job , 'role.value' , '' ) ,
211- rateType : 'weekly' , // hardcode for now
212- workload : _ . get ( job , 'workLoad.title' , '' ) . toLowerCase ( ) ,
213- } ) . then ( ( createdJob ) => {
214- app . logger . debug ( `jobId: ${ createdJob . id } job created with title "${ createdJob . title } "` ) ;
215- } ) . catch ( ( err ) => {
216- app . logger . error ( `Unable to create job with title "${ job . title } ": ${ err . message } ` ) ;
217- } ) ;
218- } ,
219- ) ,
220- ) ;
221- }
222- } catch ( error ) {
223- app . logger . error ( `Error while creating TaaS jobs: ${ error } ` ) ;
224- }
225167}
226168
227169module . exports = {
0 commit comments