diff --git a/.circleci/config.yml b/.circleci/config.yml index e63a37ba..e22ef291 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -11,7 +11,7 @@ install_dependency: &install_dependency install_deploysuite: &install_deploysuite name: Installation of install_deploysuite. command: | - git clone --branch v1.4.6 https://github.com/topcoder-platform/tc-deploy-scripts ../buildscript + git clone --branch master https://github.com/topcoder-platform/tc-deploy-scripts ../buildscript cp ./../buildscript/master_deploy.sh . cp ./../buildscript/buildenv.sh . cp ./../buildscript/awsconfiguration.sh . diff --git a/data/demo-data.json b/data/demo-data.json index 59b2ba50..aad3fbe7 100644 --- a/data/demo-data.json +++ b/data/demo-data.json @@ -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": [ { @@ -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": [ { @@ -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": [ { diff --git a/migrations/2021-06-18-make-payment-scheduler-step-optional.js b/migrations/2021-06-18-make-payment-scheduler-step-optional.js new file mode 100644 index 00000000..ddcecef1 --- /dev/null +++ b/migrations/2021-06-18-make-payment-scheduler-step-optional.js @@ -0,0 +1,15 @@ +const config = require('config') +const _ = require('lodash') +const { PaymentSchedulerStatus } = require('../app-constants') +/* + * Make Job payment_schedulers step optional. + */ + +module.exports = { + up: async (queryInterface, Sequelize) => { + await queryInterface.sequelize.query(`ALTER TABLE ${config.DB_SCHEMA_NAME}.payment_schedulers ALTER COLUMN step DROP NOT NULL`) + }, + down: async (queryInterface, Sequelize) => { + await queryInterface.sequelize.query(`ALTER TABLE ${config.DB_SCHEMA_NAME}.payment_schedulers ALTER COLUMN step SET NOT NULL`) + } +} \ No newline at end of file diff --git a/scripts/demo-payment-scheduler/data.json b/scripts/demo-payment-scheduler/data.json index 5023842c..8eafffec 100644 --- a/scripts/demo-payment-scheduler/data.json +++ b/scripts/demo-payment-scheduler/data.json @@ -43,6 +43,8 @@ "startDate":"2020-09-27", "endDate":"2020-10-03", "daysWorked":4, + "daysPaid": 3, + "paymentTotal": 0, "memberRate":27.06, "customerRate":13.13, "paymentStatus":"partially-completed", @@ -59,6 +61,8 @@ "startDate":"2020-10-18", "endDate":"2020-10-24", "daysWorked":4, + "daysPaid": 3, + "paymentTotal": 0, "memberRate":4.08, "customerRate":3.89, "paymentStatus":"cancelled", @@ -75,6 +79,8 @@ "startDate":"2020-10-25", "endDate":"2020-10-31", "daysWorked":3, + "daysPaid": 3, + "paymentTotal": 0, "memberRate":15.61, "customerRate":9.76, "paymentStatus":"pending", @@ -91,6 +97,8 @@ "startDate":"2020-10-11", "endDate":"2020-10-17", "daysWorked":4, + "daysPaid": 3, + "paymentTotal": 0, "memberRate":10.82, "customerRate":30.71, "paymentStatus":"pending", diff --git a/scripts/demo-payment-scheduler/index.js b/scripts/demo-payment-scheduler/index.js index 8f76a814..5cb0a0b5 100644 --- a/scripts/demo-payment-scheduler/index.js +++ b/scripts/demo-payment-scheduler/index.js @@ -13,6 +13,8 @@ for (let i = 0; i < 1000; i++) { amount: _.round(_.random(1000, true), 2), status: 'scheduled', billingAccountId: data.ResourceBooking.billingAccountId, + memberRate: data.ResourceBooking.memberRate, + days: 4, createdBy: '57646ff9-1cd3-4d3c-88ba-eb09a395366c', updatedBy: null, createdAt: `2021-05-19T21:3${i % 10}:46.507Z`, diff --git a/src/models/PaymentScheduler.js b/src/models/PaymentScheduler.js index f8f64dfa..c030ef04 100644 --- a/src/models/PaymentScheduler.js +++ b/src/models/PaymentScheduler.js @@ -50,8 +50,7 @@ module.exports = (sequelize) => { allowNull: false }, step: { - type: Sequelize.ENUM(_.values(PaymentSchedulerStatus)), - allowNull: false + type: Sequelize.ENUM(_.values(PaymentSchedulerStatus)) }, status: { type: Sequelize.ENUM( diff --git a/src/services/PaymentSchedulerService.js b/src/services/PaymentSchedulerService.js index 5fdb903b..b07694e4 100644 --- a/src/services/PaymentSchedulerService.js +++ b/src/services/PaymentSchedulerService.js @@ -131,7 +131,7 @@ async function processPayment (workPeriodPayment) { await postEvent(config.TAAS_WORK_PERIOD_PAYMENT_UPDATE_TOPIC, updated.toJSON(), { oldValue }) if (paymentScheduler) { - await paymentScheduler.update({ step: PaymentSchedulerStatus.CLOSE_CHALLENGE, userId: paymentScheduler.userId, status: 'failed' }) + await paymentScheduler.update({ step: _.get(err, 'step'), userId: paymentScheduler.userId, status: 'failed' }) } localLogger.error(`Processed workPeriodPayment ${workPeriodPayment.id} failed`, 'processPayment') return processResult.FAIL diff --git a/src/services/TeamService.js b/src/services/TeamService.js index c5276332..717bf396 100644 --- a/src/services/TeamService.js +++ b/src/services/TeamService.js @@ -760,7 +760,7 @@ async function roleSearchRequest (currentUser, data) { if (!_.isUndefined(data.roleId)) { role = await Role.findById(data.roleId) role = role.toJSON() - role.skillsMatch = 1; + role.skillsMatch = 1 // if skills is provided then use skills to find role } else if (!_.isUndefined(data.skills)) { // validate given skillIds and convert them into skill names @@ -802,30 +802,16 @@ roleSearchRequest.schema = Joi.object() * @returns {Role} the best matching Role */ async function getRoleBySkills (skills) { - // Case-insensitive search for roles matching any of the given skills - const lowerCaseSkills = skills.map(skill => skill.toLowerCase()) + // find all roles which includes any of the given skills const queryCriteria = { - where: where( - fn( - 'string_to_array', - fn( - 'lower', - fn( - 'array_to_string', - col('list_of_skills'), - ',' - ) - ), - ',' - ), - {[Op.overlap]: lowerCaseSkills }), + where: { listOfSkills: { [Op.overlap]: skills } }, raw: true } const roles = await Role.findAll(queryCriteria) if (roles.length > 0) { let result = _.each(roles, role => { - // calculate each found roles matching rate (must again be made case-insensitive) - role.skillsMatch = _.intersection(role.listOfSkills.map(skill => skill.toLowerCase()), lowerCaseSkills).length / skills.length + // calculate each found roles matching rate + role.skillsMatch = _.intersection(role.listOfSkills, skills).length / skills.length // each role can have multiple rates, get the maximum of global rates role.maxGlobal = _.maxBy(role.rates, 'global').global }) @@ -837,7 +823,7 @@ async function getRoleBySkills (skills) { } } // if no matching role found then return Custom role or empty object - return await Role.findOne({ where: { name: { [Op.iLike]: 'Custom' } } }) || {} + return await Role.findOne({ where: { name: { [Op.iLike]: 'Custom' } }, raw: true }) || {} } getRoleBySkills.schema = Joi.object()