Skip to content

Commit 136a574

Browse files
authored
Merge pull request #469 from topcoder-platform/dev
[PROD] Next Release
2 parents 44623e1 + aa470aa commit 136a574

File tree

8 files changed

+160
-26
lines changed

8 files changed

+160
-26
lines changed

config/default.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ module.exports = {
177177
DEFAULT_TIMELINE_TEMPLATE_ID: process.env.DEFAULT_TIMELINE_TEMPLATE_ID || '53a307ce-b4b3-4d6f-b9a1-3741a58f77e6',
178178
DEFAULT_TRACK_ID: process.env.DEFAULT_TRACK_ID || '9b6fc876-f4d9-4ccb-9dfd-419247628825',
179179
// the minimum matching rate when searching roles by skills
180-
ROLE_MATCHING_RATE: process.env.ROLE_MATCHING_RATE || 0.70,
180+
ROLE_MATCHING_RATE: process.env.ROLE_MATCHING_RATE || 0.66,
181181
// member groups representing Wipro or TopCoder employee
182182
INTERNAL_MEMBER_GROUPS: process.env.INTERNAL_MEMBER_GROUPS || ['20000000', '20000001', '20000003', '20000010', '20000015'],
183183
// Topcoder skills cache time in minutes
@@ -265,5 +265,8 @@ module.exports = {
265265
// The interview completed past time for fetching interviews
266266
INTERVIEW_COMPLETED_PAST_TIME: process.env.INTERVIEW_COMPLETED_PAST_TIME || 'PT4H',
267267
// The time before resource booking expiry when we should start sending notifications
268-
RESOURCE_BOOKING_EXPIRY_TIME: process.env.RESOURCE_BOOKING_EXPIRY_TIME || 'P21D'
268+
RESOURCE_BOOKING_EXPIRY_TIME: process.env.RESOURCE_BOOKING_EXPIRY_TIME || 'P21D',
269+
// The Stripe
270+
STRIPE_SECRET_KEY: process.env.STRIPE_SECRET_KEY,
271+
CURRENCY: process.env.CURRENCY || 'usd'
269272
}

docs/swagger.yaml

Lines changed: 64 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3538,7 +3538,56 @@ paths:
35383538
content:
35393539
application/json:
35403540
schema:
3541-
$ref: "#/components/schemas/Error"
3541+
$ref: "#/components/schemas/Error"
3542+
/taas-teams/isExternalMember:
3543+
post:
3544+
tags:
3545+
- Teams
3546+
description: |
3547+
Finds whether member is internal or external
3548+
3549+
requestBody:
3550+
content:
3551+
application/json:
3552+
schema:
3553+
$ref: "#/components/schemas/IsExternalMemberRequestBody"
3554+
responses:
3555+
"200":
3556+
description: OK
3557+
content:
3558+
application/json:
3559+
schema:
3560+
$ref: "#/components/schemas/IsExternalMemberResponse"
3561+
"400":
3562+
description: Bad request
3563+
content:
3564+
application/json:
3565+
schema:
3566+
$ref: "#/components/schemas/Error"
3567+
"401":
3568+
description: Not authenticated
3569+
content:
3570+
application/json:
3571+
schema:
3572+
$ref: "#/components/schemas/Error"
3573+
"403":
3574+
description: Forbidden
3575+
content:
3576+
application/json:
3577+
schema:
3578+
$ref: "#/components/schemas/Error"
3579+
"409":
3580+
description: Conflict
3581+
content:
3582+
application/json:
3583+
schema:
3584+
$ref: "#/components/schemas/Error"
3585+
"500":
3586+
description: Internal Server Error
3587+
content:
3588+
application/json:
3589+
schema:
3590+
$ref: "#/components/schemas/Error"
35423591
/taas-teams/members-suggest/{fragment}:
35433592
get:
35443593
tags:
@@ -5754,12 +5803,9 @@ components:
57545803
numberOfResources:
57555804
type: number
57565805
description: "No. of resources required."
5757-
rates:
5806+
rate:
57585807
type: number
57595808
description: "Weekly rates"
5760-
durationWeeks:
5761-
type: number
5762-
description: "No. of weeks"
57635809
CalculateAmountResponse:
57645810
properties:
57655811
totalAmount:
@@ -5775,6 +5821,16 @@ components:
57755821
paymentIntentToken:
57765822
type: string
57775823
description: " Token required by stripe for completing payment."
5824+
IsExternalMemberRequestBody:
5825+
properties:
5826+
totalAmount:
5827+
type: number
5828+
description: "Member id"
5829+
IsExternalMemberResponse:
5830+
properties:
5831+
paymentIntentToken:
5832+
type: boolean
5833+
description: "Is the user external member"
57785834
SubmitTeamRequestBody:
57795835
properties:
57805836
teamName:
@@ -5786,6 +5842,9 @@ components:
57865842
refCode:
57875843
type: string
57885844
description: "Optional referral code"
5845+
intakeSource:
5846+
type: string
5847+
description: "The source of the intake."
57895848
positions:
57905849
type: array
57915850
description: "The array of positions"

src/controllers/TeamController.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,16 @@ async function createPayment(req, res) {
173173
res.send(await service.createPayment(req.body.totalAmount));
174174
}
175175

176+
/**
177+
*
178+
* @param req the request
179+
* @param res the response
180+
*/
181+
async function isExternalMember(req, res) {
182+
res.send(await service.isExternalMember(req.body.memberId));
183+
}
184+
185+
176186
module.exports = {
177187
searchTeams,
178188
getTeam,
@@ -189,5 +199,6 @@ module.exports = {
189199
searchSkills,
190200
suggestMembers,
191201
createPayment,
192-
calculateAmount
202+
calculateAmount,
203+
isExternalMember
193204
}

src/routes/TeamRoutes.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,24 @@ module.exports = {
112112
post: {
113113
controller: "TeamController",
114114
method: "calculateAmount",
115+
auth: 'jwt',
116+
scopes: [constants.Scopes.CREATE_TAAS_TEAM]
115117
},
116118
},
117119
"/taas-teams/createPayment": {
118120
post: {
119121
controller: "TeamController",
120122
method: "createPayment",
123+
auth: 'jwt',
124+
scopes: [constants.Scopes.CREATE_TAAS_TEAM]
125+
},
126+
},
127+
"/taas-teams/isExternalMember": {
128+
post: {
129+
controller: "TeamController",
130+
method: "isExternalMember",
131+
auth: 'jwt',
132+
scopes: []
133+
}
121134
},
122-
}
123135
}

src/services/EmailNotificationService.js

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ async function getProjectWithId (projectId) {
3333
project = await helper.getProjectById(helper.getAuditM2Muser(), projectId)
3434
} catch (err) {
3535
localLogger.error(
36-
`exception fetching project with id: ${projectId} Status Code: ${err.status} message: ${err.response.text}`, 'getProjectWithId')
36+
`exception fetching project with id: ${projectId} Status Code: ${err.status} message: ${_.get(err, 'response.text', err.toString())}`, 'getProjectWithId')
3737
}
3838

3939
return project
@@ -65,7 +65,7 @@ async function getUserWithId (userId) {
6565
user = await helper.ensureUserById(userId)
6666
} catch (err) {
6767
localLogger.error(
68-
`exception fetching user with id: ${userId} Status Code: ${err.status} message: ${err.response.text}`, 'getUserWithId')
68+
`exception fetching user with id: ${userId} Status Code: ${err.status} message: ${_.get(err, 'response.text', err.toString())}`, 'getUserWithId')
6969
}
7070

7171
return user
@@ -120,7 +120,11 @@ async function sendCandidatesAvailableEmails () {
120120
const jobs = _.map(jobsDao, dao => dao.dataValues)
121121

122122
const projectIds = _.uniq(_.map(jobs, job => job.projectId))
123+
124+
localLogger.debug(`[sendCandidatesAvailableEmails]: Found ${projectIds.length} projects with Job Candidates awaiting for review.`)
125+
123126
// for each unique project id, send an email
127+
let sentCount = 0
124128
for (const projectId of projectIds) {
125129
const project = await getProjectWithId(projectId)
126130
if (!project) { continue }
@@ -172,7 +176,10 @@ async function sendCandidatesAvailableEmails () {
172176
description: 'Candidates are available for review'
173177
}
174178
})
179+
180+
sentCount++
175181
}
182+
localLogger.debug(`[sendCandidatesAvailableEmails]: Sent notifications for ${sentCount} of ${projectIds.length} projects with Job Candidates awaiting for review.`)
176183
}
177184

178185
/**
@@ -216,6 +223,10 @@ async function sendInterviewComingUpEmails () {
216223
raw: true
217224
})
218225

226+
localLogger.debug(`[sendInterviewComingUpEmails]: Found ${interviews.length} interviews which are coming soon.`)
227+
228+
let sentHostCount = 0
229+
let sentGuestCount = 0
219230
for (const interview of interviews) {
220231
// send host email
221232
const data = await getDataForInterview(interview)
@@ -233,6 +244,8 @@ async function sendInterviewComingUpEmails () {
233244
description: 'Interview Coming Up'
234245
}
235246
})
247+
248+
sentHostCount++
236249
} else {
237250
localLogger.error(`Interview id: ${interview.id} host email not present`, 'sendInterviewComingUpEmails')
238251
}
@@ -250,10 +263,14 @@ async function sendInterviewComingUpEmails () {
250263
description: 'Interview Coming Up'
251264
}
252265
})
266+
267+
sentGuestCount++
253268
} else {
254269
localLogger.error(`Interview id: ${interview.id} guest emails not present`, 'sendInterviewComingUpEmails')
255270
}
256271
}
272+
273+
localLogger.debug(`[sendInterviewComingUpEmails]: Sent notifications for ${sentHostCount} hosts and ${sentGuestCount} guest of ${interviews.length} interviews which are coming soon.`)
257274
}
258275

259276
/**
@@ -288,6 +305,9 @@ async function sendInterviewCompletedEmails () {
288305
raw: true
289306
})
290307

308+
localLogger.debug(`[sendInterviewCompletedEmails]: Found ${interviews.length} interviews which must be ended by now.`)
309+
310+
let sentCount = 0
291311
for (const interview of interviews) {
292312
if (_.isEmpty(interview.hostEmail)) {
293313
localLogger.error(`Interview id: ${interview.id} host email not present`)
@@ -308,7 +328,11 @@ async function sendInterviewCompletedEmails () {
308328
description: 'Interview Completed'
309329
}
310330
})
331+
332+
sentCount++
311333
}
334+
335+
localLogger.debug(`[sendInterviewCompletedEmails]: Sent notifications for ${sentCount} of ${interviews.length} interviews which must be ended by now.`)
312336
}
313337

314338
/**
@@ -341,6 +365,10 @@ async function sendPostInterviewActionEmails () {
341365
})
342366

343367
const projectIds = _.uniq(_.map(jobs, job => job.projectId))
368+
369+
localLogger.debug(`[sendPostInterviewActionEmails]: Found ${projectIds.length} projects with ${completedJobCandidates.length} Job Candidates with interview completed awaiting for an action.`)
370+
371+
let sentCount = 0
344372
for (const projectId of projectIds) {
345373
const project = await getProjectWithId(projectId)
346374
if (!project) { continue }
@@ -374,7 +402,11 @@ async function sendPostInterviewActionEmails () {
374402
description: 'Post Interview Candidate Action Reminder'
375403
}
376404
})
405+
406+
sentCount++
377407
}
408+
409+
localLogger.debug(`[sendPostInterviewActionEmails]: Sent notifications for ${sentCount} of ${projectIds.length} projects with Job Candidates with interview completed awaiting for an action.`)
378410
}
379411

380412
/**
@@ -410,6 +442,9 @@ async function sendResourceBookingExpirationEmails () {
410442
})
411443
const projectIds = _.uniq(_.map(expiringResourceBookings, rb => rb.projectId))
412444

445+
localLogger.debug(`[sendResourceBookingExpirationEmails]: Found ${projectIds.length} projects with ${expiringResourceBookings.length} Resource Bookings expiring in less than 3 weeks.`)
446+
447+
let sentCount = 0
413448
for (const projectId of projectIds) {
414449
const project = await getProjectWithId(projectId)
415450
if (!project) { continue }
@@ -447,7 +482,11 @@ async function sendResourceBookingExpirationEmails () {
447482
description: 'Upcoming Resource Booking Expiration'
448483
}
449484
})
485+
486+
sentCount++
450487
}
488+
489+
localLogger.debug(`[sendResourceBookingExpirationEmails]: Sent notifications for ${sentCount} of ${projectIds.length} projects with Resource Bookings expiring in less than 3 weeks.`)
451490
}
452491

453492
/**

src/services/PaymentService.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ async function createChallenge (challenge, token) {
9696
return challengeId
9797
} catch (err) {
9898
localLogger.error({ context: 'createChallenge', message: `Status Code: ${err.status}` })
99-
localLogger.error({ context: 'createChallenge', message: err.response.text })
99+
localLogger.error({ context: 'createChallenge', message: _.get(err, 'response.text', err.toString()) })
100100
throw err
101101
}
102102
}
@@ -126,7 +126,7 @@ async function addResourceToChallenge (id, handle, token) {
126126
}
127127
}
128128
localLogger.error({ context: 'addResourceToChallenge', message: `Status Code: ${err.status}` })
129-
localLogger.error({ context: 'addResourceToChallenge', message: err.response.text })
129+
localLogger.error({ context: 'addResourceToChallenge', message: _.get(err, 'response.text', err.toString()) })
130130
throw err
131131
}
132132
}
@@ -153,7 +153,7 @@ async function activateChallenge (id, token) {
153153
}
154154
}
155155
localLogger.error({ context: 'activateChallenge', message: `Status Code: ${err.status}` })
156-
localLogger.error({ context: 'activateChallenge', message: err.response.text })
156+
localLogger.error({ context: 'activateChallenge', message: _.get(err, 'response.text', err.toString()) })
157157
throw err
158158
}
159159
}
@@ -189,7 +189,7 @@ async function closeChallenge (id, userId, userHandle, token) {
189189
}
190190
}
191191
localLogger.error({ context: 'closeChallenge', message: `Status Code: ${err.status}` })
192-
localLogger.error({ context: 'closeChallenge', message: err.response.text })
192+
localLogger.error({ context: 'closeChallenge', message: _.get(err, 'response.text', err.toString()) })
193193
throw err
194194
}
195195
}

0 commit comments

Comments
 (0)