Skip to content

TaaS Intake - v2.02 #385

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Jun 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions app-routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,36 @@ module.exports = (app) => {
next()
}
})
} else {
// public API, but still try to authenticate token if provided, but allow missing/invalid token
actions.push((req, res, next) => {
const interceptRes = {}
interceptRes.status = () => interceptRes
interceptRes.json = () => interceptRes
interceptRes.send = () => next()
authenticator(_.pick(config, ['AUTH_SECRET', 'VALID_ISSUERS']))(req, interceptRes, next)
})

actions.push((req, res, next) => {
if (!req.authUser) {
next()
} else if (req.authUser.isMachine) {
if (!def.scopes || !req.authUser.scopes || !helper.checkIfExists(def.scopes, req.authUser.scopes)) {
req.authUser = undefined
}
next()
} else {
req.authUser.jwtToken = req.headers.authorization
// check if user has full manage permission
if (_.intersection(req.authUser.roles, constants.FullManagePermissionRoles).length) {
req.authUser.hasManagePermission = true
}
if (_.includes(req.authUser.roles, constants.UserRoles.ConnectManager)) {
req.authUser.isConnectManager = true
}
next()
}
})
}

actions.push(method)
Expand Down
22 changes: 11 additions & 11 deletions data/demo-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -7646,10 +7646,10 @@
"name": "Angular Developer",
"description": "* Writes tested and documented JavaScript, HTML and CSS\n* Makes design and technical decisions for AngularJS projects\n* Develops application code and unit test in the AngularJS, Rest Web Services and Java technologies",
"listOfSkills": [
"database",
"winforms",
"user interface (ui)",
"photoshop"
"Database",
"Winforms",
"User Interface (Ui)",
"Photoshop"
],
"rates": [
{
Expand Down Expand Up @@ -7678,10 +7678,10 @@
"name": "Dev Ops Engineer",
"description": "* Introduces processes, tools, and methodologies\n* Balances needs throughout the software development life cycle\n* Configures server images, optimizes task performance in correspondence with engineers",
"listOfSkills": [
"dropwizard",
"nginx",
"machine learning",
"force.com"
"Dropwizard",
"NGINX",
"Machine Learning",
"Force.com"
],
"rates": [
{
Expand Down Expand Up @@ -7722,10 +7722,10 @@
"name": "Salesforce Developer",
"description": "* Meets with project managers to determine CRM needs\n* Develops customized solutions within the Salesforce platform\n* Designs, codes, and implements Salesforce applications\n* Creates timelines and development goals\n* Tests the stability and functionality of the application\n* Troubleshoots and fixes bugs\n* Writes documents and provides technical training for Salesforce Staff\n* Maintains the security and integrity of the application software",
"listOfSkills": [
"docker",
".net",
"Docker",
".NET",
"appcelerator",
"flux"
"Flux"
],
"rates": [
{
Expand Down
114 changes: 10 additions & 104 deletions docs/Topcoder-bookings-api.postman_collection.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"info": {
"_postman_id": "6f274c86-24a5-412e-95e6-fafa34e2a936",
"_postman_id": "15f10b58-dda5-4aaf-96e5-061a5c901717",
"name": "Topcoder-bookings-api",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
Expand Down Expand Up @@ -18153,16 +18153,14 @@
"response": []
},
{
"name": "send request with invalid token",
"name": "send request with public",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test('Status code is 401', function () {\r",
" pm.response.to.have.status(401);\r",
" const response = pm.response.json()\r",
" pm.expect(response.message).to.eq(\"Invalid Token.\")\r",
"pm.test('Status code is 200', function () {\r",
" pm.response.to.have.status(200);\r",
"});"
],
"type": "text/javascript"
Expand All @@ -18171,16 +18169,10 @@
],
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"value": "Bearer invalid_token",
"type": "text"
}
],
"header": [],
"body": {
"mode": "raw",
"raw": "{\r\n \"jobDescription\": \"Should have these skills: Machine Learning, Dropwizard, NGINX, appcelerator\"\r\n}",
"raw": "{\r\n \"jobDescription\": \"Should have these skills: Machine Learning, Dropwizard, NGINX, appcelerator, C#\"\r\n}",
"options": {
"raw": {
"language": "json"
Expand Down Expand Up @@ -18210,7 +18202,7 @@
"pm.test('Status code is 400', function () {\r",
" pm.response.to.have.status(400);\r",
" const response = pm.response.json()\r",
" pm.expect(response.message).to.eq(\"\\\"data\\\" must have at least 1 key\")\r",
" pm.expect(response.message).to.eq(\"\\\"data\\\" must contain at least one of [roleId, jobDescription, skills]\")\r",
"});"
],
"type": "text/javascript"
Expand Down Expand Up @@ -19211,71 +19203,7 @@
],
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"type": "text",
"value": "Bearer {{token_administrator}}"
},
{
"key": "Content-Type",
"type": "text",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{ \"description\": \"Description A global leading healthcare company is seeking a strong Databricks Engineer to join their development team as they build their new Databricks workspace. Development efforts will contribute to the migration of data from Hadoop to Databricks to prepare data for visualization. Candidate must be well-versed in Databricks components and best practices, be an excellent problem solver and be comfortable working in a fast-moving, rapidly changing, and dynamic environment via Agile, SCRUM, and DevOps. PREFERRED QUALIFICATIONS: 2+ years of Azure Data Stack experience: Azure Data Services using ADF, ADLS, Databricks with PySpark, Azure DevOps & Azure Key Vault. Strong knowledge of various data warehousing methodologies and data modeling concepts. Hands-on experience using Azure, Azure data lake, Azure functions & Databricks Minimum 2-3+ years of Python experience (PySpark) Design & Develop Azure native solutions for Data Platform Minimum 3+ years of experience using Big Data ecosystem (Cloudera/Hortonworks) using Oozie, Hive, Impala, and Spark Expert in SQL and performance tuning\" }",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{URL}}/taas-teams/getSkillsByJobDescription",
"host": [
"{{URL}}"
],
"path": [
"taas-teams",
"getSkillsByJobDescription"
]
}
},
"response": []
},
{
"name": "get skills by invalid token",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test('Status code is 401', function () {\r",
" pm.response.to.have.status(401);\r",
" const response = pm.response.json()\r",
" pm.expect(response.message).to.eq(\"Invalid Token.\")\r",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"type": "text",
"value": "Bearer invalid_token"
},
{
"key": "Content-Type",
"type": "text",
"value": "application/json"
}
],
"header": [],
"body": {
"mode": "raw",
"raw": "{ \"description\": \"Description A global leading healthcare company is seeking a strong Databricks Engineer to join their development team as they build their new Databricks workspace. Development efforts will contribute to the migration of data from Hadoop to Databricks to prepare data for visualization. Candidate must be well-versed in Databricks components and best practices, be an excellent problem solver and be comfortable working in a fast-moving, rapidly changing, and dynamic environment via Agile, SCRUM, and DevOps. PREFERRED QUALIFICATIONS: 2+ years of Azure Data Stack experience: Azure Data Services using ADF, ADLS, Databricks with PySpark, Azure DevOps & Azure Key Vault. Strong knowledge of various data warehousing methodologies and data modeling concepts. Hands-on experience using Azure, Azure data lake, Azure functions & Databricks Minimum 2-3+ years of Python experience (PySpark) Design & Develop Azure native solutions for Data Platform Minimum 3+ years of experience using Big Data ecosystem (Cloudera/Hortonworks) using Oozie, Hive, Impala, and Spark Expert in SQL and performance tuning\" }",
Expand Down Expand Up @@ -19317,18 +19245,7 @@
],
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"type": "text",
"value": "Bearer {{token_administrator}}"
},
{
"key": "Content-Type",
"type": "text",
"value": "application/json"
}
],
"header": [],
"body": {
"mode": "raw",
"raw": "{ \"description\": \"\" }",
Expand Down Expand Up @@ -19370,18 +19287,7 @@
],
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"type": "text",
"value": "Bearer {{token_administrator}}"
},
{
"key": "Content-Type",
"type": "text",
"value": "application/json"
}
],
"header": [],
"body": {
"mode": "raw",
"raw": "{}",
Expand Down
7 changes: 7 additions & 0 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5249,6 +5249,9 @@ components:
jobDescription:
type: string
description: "The description of the job."
jobTitle:
type: string
description: "An optional job title."
- type: object
required:
- skills
Expand Down Expand Up @@ -5281,6 +5284,10 @@ components:
format: float
description: "Rate at which searched skills match the given role"
example: 0.75
jobTitle:
type: string
description: "Optional job title."
example: "Lead Application Developer"
SubmitTeamRequestBody:
properties:
teamName:
Expand Down
18 changes: 18 additions & 0 deletions migrations/2021-06-22-role-search-request-add-job-title.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const config = require('config')

/**
* Add jobTitle field to the RoleSearchRequest model.
*/

module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.addColumn({ tableName: 'role_search_requests', schema: config.DB_SCHEMA_NAME }, 'job_title',
{
type: Sequelize.STRING(100),
allowNull: true
})
},
down: async (queryInterface, Sequelize) => {
await queryInterface.removeColumn({ tableName: 'role_search_requests', schema: config.DB_SCHEMA_NAME}, 'job_title')
}
}
4 changes: 2 additions & 2 deletions src/common/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -1960,8 +1960,8 @@ function removeTextFormatting (text) {
// Remove footnotes
text = _.replace(text, /\[\^.+?\](: .*?$)?/g, ' ')
text = _.replace(text, /\s{0,2}\[.*?\]: .*?$/g, ' ')
// Remove images
text = _.replace(text, /!\[(.*?)\][[(].*?[\])]/g, ' $1 ')
// Remove images and keep description unless it is default description "image"
text = _.replace(text, /!(\[((?!image).*?)\]|\[.*?\])[[(].*?[\])]/g, ' $2 ')
// Remove inline links
text = _.replace(text, /\[(.*?)\][[(].*?[\])]/g, ' $1 ')
// Remove blockquotes
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/TeamController.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ async function getMe (req, res) {
* @param res the response
*/
async function getSkillsByJobDescription (req, res) {
res.send(await service.getSkillsByJobDescription(req.authUser, req.body))
res.send(await service.getSkillsByJobDescription(req.body))
}

/**
Expand Down
5 changes: 5 additions & 0 deletions src/models/RoleSearchRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ module.exports = (sequelize) => {
type: Sequelize.UUID
})
},
jobTitle: {
field: 'job_title',
type: Sequelize.STRING(100),
allowNull: true
},
createdBy: {
field: 'created_by',
type: Sequelize.UUID,
Expand Down
8 changes: 3 additions & 5 deletions src/routes/TeamRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = {
'/taas-teams/skills': {
get: {
controller: 'TeamController',
method: 'searchSkills',
method: 'searchSkills'
}
},
'/taas-teams/me': {
Expand All @@ -37,9 +37,7 @@ module.exports = {
'/taas-teams/getSkillsByJobDescription': {
post: {
controller: 'TeamController',
method: 'getSkillsByJobDescription',
auth: 'jwt',
scopes: [constants.Scopes.READ_TAAS_TEAM]
method: 'getSkillsByJobDescription'
}
},
'/taas-teams/:id': {
Expand Down Expand Up @@ -91,7 +89,7 @@ module.exports = {
'/taas-teams/sendRoleSearchRequest': {
post: {
controller: 'TeamController',
method: 'roleSearchRequest',
method: 'roleSearchRequest'
}
},
'/taas-teams/submitTeamRequest': {
Expand Down
6 changes: 3 additions & 3 deletions src/services/PaymentSchedulerService.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ async function processPayment (workPeriodPayment) {
const oldValue = workPeriodPayment.toJSON()
const updated = await workPeriodPayment.update({ status: 'in-progress' })
// Update the modified status to es
await postEvent(config.TAAS_WORK_PERIOD_PAYMENT_UPDATE_TOPIC, updated.toJSON(), { oldValue })
await postEvent(config.TAAS_WORK_PERIOD_PAYMENT_UPDATE_TOPIC, updated.toJSON(), { oldValue, key: `workPeriodPayment.billingAccountId:${updated.billingAccountId}` })
}
// Check whether the number of processed records per minute exceeds the specified number, if it exceeds, wait for the next minute before processing
await checkWait(PaymentSchedulerStatus.START_PROCESS)
Expand All @@ -115,7 +115,7 @@ async function processPayment (workPeriodPayment) {
// 5. update wp and save it should only update already existent Work Period Payment record with created "challengeId" and "status=completed".
const updated = await workPeriodPayment.update({ challengeId: paymentScheduler.challengeId, status: 'completed' })
// Update the modified status to es
await postEvent(config.TAAS_WORK_PERIOD_PAYMENT_UPDATE_TOPIC, updated.toJSON(), { oldValue })
await postEvent(config.TAAS_WORK_PERIOD_PAYMENT_UPDATE_TOPIC, updated.toJSON(), { oldValue, key: `workPeriodPayment.billingAccountId:${updated.billingAccountId}` })

await paymentScheduler.update({ step: PaymentSchedulerStatus.CLOSE_CHALLENGE, userId: paymentScheduler.userId, status: 'completed' })

Expand All @@ -128,7 +128,7 @@ async function processPayment (workPeriodPayment) {
// If payment processing failed Work Periods Payment "status" should be changed to "failed" and populate "statusDetails" field with error details in JSON format.
const updated = await workPeriodPayment.update({ statusDetails, status: 'failed' })
// Update the modified status to es
await postEvent(config.TAAS_WORK_PERIOD_PAYMENT_UPDATE_TOPIC, updated.toJSON(), { oldValue })
await postEvent(config.TAAS_WORK_PERIOD_PAYMENT_UPDATE_TOPIC, updated.toJSON(), { oldValue, key: `workPeriodPayment.billingAccountId:${updated.billingAccountId}` })

if (paymentScheduler) {
await paymentScheduler.update({ step: _.get(err, 'step'), userId: paymentScheduler.userId, status: 'failed' })
Expand Down
Loading