Skip to content

Commit

Permalink
Merge pull request #469 from topcoder-platform/dev
Browse files Browse the repository at this point in the history
[PROD] Next Release
  • Loading branch information
urwithat authored Aug 16, 2021
2 parents 44623e1 + aa470aa commit 136a574
Show file tree
Hide file tree
Showing 8 changed files with 160 additions and 26 deletions.
7 changes: 5 additions & 2 deletions config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ module.exports = {
DEFAULT_TIMELINE_TEMPLATE_ID: process.env.DEFAULT_TIMELINE_TEMPLATE_ID || '53a307ce-b4b3-4d6f-b9a1-3741a58f77e6',
DEFAULT_TRACK_ID: process.env.DEFAULT_TRACK_ID || '9b6fc876-f4d9-4ccb-9dfd-419247628825',
// the minimum matching rate when searching roles by skills
ROLE_MATCHING_RATE: process.env.ROLE_MATCHING_RATE || 0.70,
ROLE_MATCHING_RATE: process.env.ROLE_MATCHING_RATE || 0.66,
// member groups representing Wipro or TopCoder employee
INTERNAL_MEMBER_GROUPS: process.env.INTERNAL_MEMBER_GROUPS || ['20000000', '20000001', '20000003', '20000010', '20000015'],
// Topcoder skills cache time in minutes
Expand Down Expand Up @@ -265,5 +265,8 @@ module.exports = {
// The interview completed past time for fetching interviews
INTERVIEW_COMPLETED_PAST_TIME: process.env.INTERVIEW_COMPLETED_PAST_TIME || 'PT4H',
// The time before resource booking expiry when we should start sending notifications
RESOURCE_BOOKING_EXPIRY_TIME: process.env.RESOURCE_BOOKING_EXPIRY_TIME || 'P21D'
RESOURCE_BOOKING_EXPIRY_TIME: process.env.RESOURCE_BOOKING_EXPIRY_TIME || 'P21D',
// The Stripe
STRIPE_SECRET_KEY: process.env.STRIPE_SECRET_KEY,
CURRENCY: process.env.CURRENCY || 'usd'
}
69 changes: 64 additions & 5 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3538,7 +3538,56 @@ paths:
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
$ref: "#/components/schemas/Error"
/taas-teams/isExternalMember:
post:
tags:
- Teams
description: |
Finds whether member is internal or external
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/IsExternalMemberRequestBody"
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/IsExternalMemberResponse"
"400":
description: Bad request
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"401":
description: Not authenticated
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"403":
description: Forbidden
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"409":
description: Conflict
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"500":
description: Internal Server Error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
/taas-teams/members-suggest/{fragment}:
get:
tags:
Expand Down Expand Up @@ -5754,12 +5803,9 @@ components:
numberOfResources:
type: number
description: "No. of resources required."
rates:
rate:
type: number
description: "Weekly rates"
durationWeeks:
type: number
description: "No. of weeks"
CalculateAmountResponse:
properties:
totalAmount:
Expand All @@ -5775,6 +5821,16 @@ components:
paymentIntentToken:
type: string
description: " Token required by stripe for completing payment."
IsExternalMemberRequestBody:
properties:
totalAmount:
type: number
description: "Member id"
IsExternalMemberResponse:
properties:
paymentIntentToken:
type: boolean
description: "Is the user external member"
SubmitTeamRequestBody:
properties:
teamName:
Expand All @@ -5786,6 +5842,9 @@ components:
refCode:
type: string
description: "Optional referral code"
intakeSource:
type: string
description: "The source of the intake."
positions:
type: array
description: "The array of positions"
Expand Down
13 changes: 12 additions & 1 deletion src/controllers/TeamController.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,16 @@ async function createPayment(req, res) {
res.send(await service.createPayment(req.body.totalAmount));
}

/**
*
* @param req the request
* @param res the response
*/
async function isExternalMember(req, res) {
res.send(await service.isExternalMember(req.body.memberId));
}


module.exports = {
searchTeams,
getTeam,
Expand All @@ -189,5 +199,6 @@ module.exports = {
searchSkills,
suggestMembers,
createPayment,
calculateAmount
calculateAmount,
isExternalMember
}
14 changes: 13 additions & 1 deletion src/routes/TeamRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,24 @@ module.exports = {
post: {
controller: "TeamController",
method: "calculateAmount",
auth: 'jwt',
scopes: [constants.Scopes.CREATE_TAAS_TEAM]
},
},
"/taas-teams/createPayment": {
post: {
controller: "TeamController",
method: "createPayment",
auth: 'jwt',
scopes: [constants.Scopes.CREATE_TAAS_TEAM]
},
},
"/taas-teams/isExternalMember": {
post: {
controller: "TeamController",
method: "isExternalMember",
auth: 'jwt',
scopes: []
}
},
}
}
43 changes: 41 additions & 2 deletions src/services/EmailNotificationService.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async function getProjectWithId (projectId) {
project = await helper.getProjectById(helper.getAuditM2Muser(), projectId)
} catch (err) {
localLogger.error(
`exception fetching project with id: ${projectId} Status Code: ${err.status} message: ${err.response.text}`, 'getProjectWithId')
`exception fetching project with id: ${projectId} Status Code: ${err.status} message: ${_.get(err, 'response.text', err.toString())}`, 'getProjectWithId')
}

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

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

const projectIds = _.uniq(_.map(jobs, job => job.projectId))

localLogger.debug(`[sendCandidatesAvailableEmails]: Found ${projectIds.length} projects with Job Candidates awaiting for review.`)

// for each unique project id, send an email
let sentCount = 0
for (const projectId of projectIds) {
const project = await getProjectWithId(projectId)
if (!project) { continue }
Expand Down Expand Up @@ -172,7 +176,10 @@ async function sendCandidatesAvailableEmails () {
description: 'Candidates are available for review'
}
})

sentCount++
}
localLogger.debug(`[sendCandidatesAvailableEmails]: Sent notifications for ${sentCount} of ${projectIds.length} projects with Job Candidates awaiting for review.`)
}

/**
Expand Down Expand Up @@ -216,6 +223,10 @@ async function sendInterviewComingUpEmails () {
raw: true
})

localLogger.debug(`[sendInterviewComingUpEmails]: Found ${interviews.length} interviews which are coming soon.`)

let sentHostCount = 0
let sentGuestCount = 0
for (const interview of interviews) {
// send host email
const data = await getDataForInterview(interview)
Expand All @@ -233,6 +244,8 @@ async function sendInterviewComingUpEmails () {
description: 'Interview Coming Up'
}
})

sentHostCount++
} else {
localLogger.error(`Interview id: ${interview.id} host email not present`, 'sendInterviewComingUpEmails')
}
Expand All @@ -250,10 +263,14 @@ async function sendInterviewComingUpEmails () {
description: 'Interview Coming Up'
}
})

sentGuestCount++
} else {
localLogger.error(`Interview id: ${interview.id} guest emails not present`, 'sendInterviewComingUpEmails')
}
}

localLogger.debug(`[sendInterviewComingUpEmails]: Sent notifications for ${sentHostCount} hosts and ${sentGuestCount} guest of ${interviews.length} interviews which are coming soon.`)
}

/**
Expand Down Expand Up @@ -288,6 +305,9 @@ async function sendInterviewCompletedEmails () {
raw: true
})

localLogger.debug(`[sendInterviewCompletedEmails]: Found ${interviews.length} interviews which must be ended by now.`)

let sentCount = 0
for (const interview of interviews) {
if (_.isEmpty(interview.hostEmail)) {
localLogger.error(`Interview id: ${interview.id} host email not present`)
Expand All @@ -308,7 +328,11 @@ async function sendInterviewCompletedEmails () {
description: 'Interview Completed'
}
})

sentCount++
}

localLogger.debug(`[sendInterviewCompletedEmails]: Sent notifications for ${sentCount} of ${interviews.length} interviews which must be ended by now.`)
}

/**
Expand Down Expand Up @@ -341,6 +365,10 @@ async function sendPostInterviewActionEmails () {
})

const projectIds = _.uniq(_.map(jobs, job => job.projectId))

localLogger.debug(`[sendPostInterviewActionEmails]: Found ${projectIds.length} projects with ${completedJobCandidates.length} Job Candidates with interview completed awaiting for an action.`)

let sentCount = 0
for (const projectId of projectIds) {
const project = await getProjectWithId(projectId)
if (!project) { continue }
Expand Down Expand Up @@ -374,7 +402,11 @@ async function sendPostInterviewActionEmails () {
description: 'Post Interview Candidate Action Reminder'
}
})

sentCount++
}

localLogger.debug(`[sendPostInterviewActionEmails]: Sent notifications for ${sentCount} of ${projectIds.length} projects with Job Candidates with interview completed awaiting for an action.`)
}

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

localLogger.debug(`[sendResourceBookingExpirationEmails]: Found ${projectIds.length} projects with ${expiringResourceBookings.length} Resource Bookings expiring in less than 3 weeks.`)

let sentCount = 0
for (const projectId of projectIds) {
const project = await getProjectWithId(projectId)
if (!project) { continue }
Expand Down Expand Up @@ -447,7 +482,11 @@ async function sendResourceBookingExpirationEmails () {
description: 'Upcoming Resource Booking Expiration'
}
})

sentCount++
}

localLogger.debug(`[sendResourceBookingExpirationEmails]: Sent notifications for ${sentCount} of ${projectIds.length} projects with Resource Bookings expiring in less than 3 weeks.`)
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/services/PaymentService.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ async function createChallenge (challenge, token) {
return challengeId
} catch (err) {
localLogger.error({ context: 'createChallenge', message: `Status Code: ${err.status}` })
localLogger.error({ context: 'createChallenge', message: err.response.text })
localLogger.error({ context: 'createChallenge', message: _.get(err, 'response.text', err.toString()) })
throw err
}
}
Expand Down Expand Up @@ -126,7 +126,7 @@ async function addResourceToChallenge (id, handle, token) {
}
}
localLogger.error({ context: 'addResourceToChallenge', message: `Status Code: ${err.status}` })
localLogger.error({ context: 'addResourceToChallenge', message: err.response.text })
localLogger.error({ context: 'addResourceToChallenge', message: _.get(err, 'response.text', err.toString()) })
throw err
}
}
Expand All @@ -153,7 +153,7 @@ async function activateChallenge (id, token) {
}
}
localLogger.error({ context: 'activateChallenge', message: `Status Code: ${err.status}` })
localLogger.error({ context: 'activateChallenge', message: err.response.text })
localLogger.error({ context: 'activateChallenge', message: _.get(err, 'response.text', err.toString()) })
throw err
}
}
Expand Down Expand Up @@ -189,7 +189,7 @@ async function closeChallenge (id, userId, userHandle, token) {
}
}
localLogger.error({ context: 'closeChallenge', message: `Status Code: ${err.status}` })
localLogger.error({ context: 'closeChallenge', message: err.response.text })
localLogger.error({ context: 'closeChallenge', message: _.get(err, 'response.text', err.toString()) })
throw err
}
}
Expand Down
Loading

0 comments on commit 136a574

Please sign in to comment.