Skip to content

Commit 8670e7f

Browse files
authored
Merge pull request #380 from mbaghel/roles-finalfix
Fix merge conflicts with dev for Roles Final fix
2 parents 2bc9de5 + dbaf7b1 commit 8670e7f

File tree

8 files changed

+45
-35
lines changed

8 files changed

+45
-35
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ install_dependency: &install_dependency
1111
install_deploysuite: &install_deploysuite
1212
name: Installation of install_deploysuite.
1313
command: |
14-
git clone --branch v1.4.6 https://github.com/topcoder-platform/tc-deploy-scripts ../buildscript
14+
git clone --branch master https://github.com/topcoder-platform/tc-deploy-scripts ../buildscript
1515
cp ./../buildscript/master_deploy.sh .
1616
cp ./../buildscript/buildenv.sh .
1717
cp ./../buildscript/awsconfiguration.sh .

data/demo-data.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7646,10 +7646,10 @@
76467646
"name": "Angular Developer",
76477647
"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",
76487648
"listOfSkills": [
7649-
"database",
7650-
"winforms",
7651-
"user interface (ui)",
7652-
"photoshop"
7649+
"Database",
7650+
"Winforms",
7651+
"User Interface (Ui)",
7652+
"Photoshop"
76537653
],
76547654
"rates": [
76557655
{
@@ -7678,10 +7678,10 @@
76787678
"name": "Dev Ops Engineer",
76797679
"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",
76807680
"listOfSkills": [
7681-
"dropwizard",
7682-
"nginx",
7683-
"machine learning",
7684-
"force.com"
7681+
"Dropwizard",
7682+
"NGINX",
7683+
"Machine Learning",
7684+
"Force.com"
76857685
],
76867686
"rates": [
76877687
{
@@ -7722,10 +7722,10 @@
77227722
"name": "Salesforce Developer",
77237723
"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",
77247724
"listOfSkills": [
7725-
"docker",
7726-
".net",
7725+
"Docker",
7726+
".NET",
77277727
"appcelerator",
7728-
"flux"
7728+
"Flux"
77297729
],
77307730
"rates": [
77317731
{
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const config = require('config')
2+
const _ = require('lodash')
3+
const { PaymentSchedulerStatus } = require('../app-constants')
4+
/*
5+
* Make Job payment_schedulers step optional.
6+
*/
7+
8+
module.exports = {
9+
up: async (queryInterface, Sequelize) => {
10+
await queryInterface.sequelize.query(`ALTER TABLE ${config.DB_SCHEMA_NAME}.payment_schedulers ALTER COLUMN step DROP NOT NULL`)
11+
},
12+
down: async (queryInterface, Sequelize) => {
13+
await queryInterface.sequelize.query(`ALTER TABLE ${config.DB_SCHEMA_NAME}.payment_schedulers ALTER COLUMN step SET NOT NULL`)
14+
}
15+
}

scripts/demo-payment-scheduler/data.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
"startDate":"2020-09-27",
4444
"endDate":"2020-10-03",
4545
"daysWorked":4,
46+
"daysPaid": 3,
47+
"paymentTotal": 0,
4648
"memberRate":27.06,
4749
"customerRate":13.13,
4850
"paymentStatus":"partially-completed",
@@ -59,6 +61,8 @@
5961
"startDate":"2020-10-18",
6062
"endDate":"2020-10-24",
6163
"daysWorked":4,
64+
"daysPaid": 3,
65+
"paymentTotal": 0,
6266
"memberRate":4.08,
6367
"customerRate":3.89,
6468
"paymentStatus":"cancelled",
@@ -75,6 +79,8 @@
7579
"startDate":"2020-10-25",
7680
"endDate":"2020-10-31",
7781
"daysWorked":3,
82+
"daysPaid": 3,
83+
"paymentTotal": 0,
7884
"memberRate":15.61,
7985
"customerRate":9.76,
8086
"paymentStatus":"pending",
@@ -91,6 +97,8 @@
9197
"startDate":"2020-10-11",
9298
"endDate":"2020-10-17",
9399
"daysWorked":4,
100+
"daysPaid": 3,
101+
"paymentTotal": 0,
94102
"memberRate":10.82,
95103
"customerRate":30.71,
96104
"paymentStatus":"pending",

scripts/demo-payment-scheduler/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ for (let i = 0; i < 1000; i++) {
1313
amount: _.round(_.random(1000, true), 2),
1414
status: 'scheduled',
1515
billingAccountId: data.ResourceBooking.billingAccountId,
16+
memberRate: data.ResourceBooking.memberRate,
17+
days: 4,
1618
createdBy: '57646ff9-1cd3-4d3c-88ba-eb09a395366c',
1719
updatedBy: null,
1820
createdAt: `2021-05-19T21:3${i % 10}:46.507Z`,

src/models/PaymentScheduler.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ module.exports = (sequelize) => {
5050
allowNull: false
5151
},
5252
step: {
53-
type: Sequelize.ENUM(_.values(PaymentSchedulerStatus)),
54-
allowNull: false
53+
type: Sequelize.ENUM(_.values(PaymentSchedulerStatus))
5554
},
5655
status: {
5756
type: Sequelize.ENUM(

src/services/PaymentSchedulerService.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ async function processPayment (workPeriodPayment) {
131131
await postEvent(config.TAAS_WORK_PERIOD_PAYMENT_UPDATE_TOPIC, updated.toJSON(), { oldValue })
132132

133133
if (paymentScheduler) {
134-
await paymentScheduler.update({ step: PaymentSchedulerStatus.CLOSE_CHALLENGE, userId: paymentScheduler.userId, status: 'failed' })
134+
await paymentScheduler.update({ step: _.get(err, 'step'), userId: paymentScheduler.userId, status: 'failed' })
135135
}
136136
localLogger.error(`Processed workPeriodPayment ${workPeriodPayment.id} failed`, 'processPayment')
137137
return processResult.FAIL

src/services/TeamService.js

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ async function roleSearchRequest (currentUser, data) {
760760
if (!_.isUndefined(data.roleId)) {
761761
role = await Role.findById(data.roleId)
762762
role = role.toJSON()
763-
role.skillsMatch = 1;
763+
role.skillsMatch = 1
764764
// if skills is provided then use skills to find role
765765
} else if (!_.isUndefined(data.skills)) {
766766
// validate given skillIds and convert them into skill names
@@ -802,30 +802,16 @@ roleSearchRequest.schema = Joi.object()
802802
* @returns {Role} the best matching Role
803803
*/
804804
async function getRoleBySkills (skills) {
805-
// Case-insensitive search for roles matching any of the given skills
806-
const lowerCaseSkills = skills.map(skill => skill.toLowerCase())
805+
// find all roles which includes any of the given skills
807806
const queryCriteria = {
808-
where: where(
809-
fn(
810-
'string_to_array',
811-
fn(
812-
'lower',
813-
fn(
814-
'array_to_string',
815-
col('list_of_skills'),
816-
','
817-
)
818-
),
819-
','
820-
),
821-
{[Op.overlap]: lowerCaseSkills }),
807+
where: { listOfSkills: { [Op.overlap]: skills } },
822808
raw: true
823809
}
824810
const roles = await Role.findAll(queryCriteria)
825811
if (roles.length > 0) {
826812
let result = _.each(roles, role => {
827-
// calculate each found roles matching rate (must again be made case-insensitive)
828-
role.skillsMatch = _.intersection(role.listOfSkills.map(skill => skill.toLowerCase()), lowerCaseSkills).length / skills.length
813+
// calculate each found roles matching rate
814+
role.skillsMatch = _.intersection(role.listOfSkills, skills).length / skills.length
829815
// each role can have multiple rates, get the maximum of global rates
830816
role.maxGlobal = _.maxBy(role.rates, 'global').global
831817
})
@@ -837,7 +823,7 @@ async function getRoleBySkills (skills) {
837823
}
838824
}
839825
// if no matching role found then return Custom role or empty object
840-
return await Role.findOne({ where: { name: { [Op.iLike]: 'Custom' } } }) || {}
826+
return await Role.findOne({ where: { name: { [Op.iLike]: 'Custom' } }, raw: true }) || {}
841827
}
842828

843829
getRoleBySkills.schema = Joi.object()

0 commit comments

Comments
 (0)