Skip to content

Commit e579f1c

Browse files
authored
Merge pull request #343 from eisbilir/feature/role-jd-parser2
Feature/role jd parser2 - final fix by winner
2 parents e76d67f + 627118d commit e579f1c

30 files changed

+2007
-155
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ workflows:
6868
branches:
6969
only:
7070
- dev
71+
- change-validatations-in-job-jc
7172

7273
# Production builds are exectuted only on tagged commits to the
7374
# master branch.

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,11 @@
103103
tc-taas-es-processor | 2021-04-09T21:20:21.469Z DEBUG no-kafka-client Subscribed to taas.workperiodpayment.update:0 offset 0 leader kafka:9093
104104
tc-taas-es-processor | 2021-04-09T21:20:21.470Z DEBUG no-kafka-client Subscribed to taas.workperiodpayment.delete:0 offset 0 leader kafka:9093
105105
tc-taas-es-processor | 2021-04-09T21:20:21.471Z DEBUG no-kafka-client Subscribed to taas.workperiodpayment.create:0 offset 0 leader kafka:9093
106+
tc-taas-es-processor | 2021-04-09T21:20:21.472Z DEBUG no-kafka-client Subscribed to taas.action.retry:0 offset 0 leader kafka:9093
106107
tc-taas-es-processor | 2021-04-09T21:20:21.473Z DEBUG no-kafka-client Subscribed to taas.job.update:0 offset 0 leader kafka:9093
107108
tc-taas-es-processor | 2021-04-09T21:20:21.474Z DEBUG no-kafka-client Subscribed to taas.resourcebooking.update:0 offset 0 leader kafka:9093
108109
tc-taas-es-processor | [2021-04-09T21:20:21.475Z] app INFO : Initialized.......
109-
tc-taas-es-processor | [2021-04-09T21:20:21.479Z] app INFO : taas.job.create,taas.job.update,taas.job.delete,taas.jobcandidate.create,taas.jobcandidate.update,taas.jobcandidate.delete,taas.resourcebooking.create,taas.resourcebooking.update,taas.resourcebooking.delete,taas.workperiod.create,taas.workperiod.update,taas.workperiod.delete,taas.workperiodpayment.create,taas.workperiodpayment.update,taas.interview.requested,taas.interview.update,taas.interview.bulkUpdate,taas.role.requested,taas.role.update,taas.role.delete
110+
tc-taas-es-processor | [2021-04-09T21:20:21.479Z] app INFO : common.error.reporting,taas.job.create,taas.job.update,taas.job.delete,taas.jobcandidate.create,taas.jobcandidate.update,taas.jobcandidate.delete,taas.resourcebooking.create,taas.resourcebooking.update,taas.resourcebooking.delete,taas.workperiod.create,taas.workperiod.update,taas.workperiod.delete,taas.workperiodpayment.create,taas.workperiodpayment.update,taas.interview.requested,taas.interview.update,taas.interview.bulkUpdate,taas.role.requested,taas.role.update,taas.role.delete,taas.action.retry
110111
tc-taas-es-processor | [2021-04-09T21:20:21.480Z] app INFO : Kick Start.......
111112
tc-taas-es-processor | ********** Topcoder Health Check DropIn listening on port 3001
112113
tc-taas-es-processor | Topcoder Health Check DropIn started and ready to roll
@@ -176,6 +177,19 @@ To be able to change and test `taas-es-processor` locally you can follow the nex
176177
2. Run `taas-es-processor` separately from the source code. As `npm run services:up` already run all the dependencies for both `taas-apis` and for `taas-es-processor`. The only thing you need to do for running `taas-es-processor` locally is clone the [taas-es-processor](https://github.com/topcoder-platform/taas-es-processor) repository and inside `taas-es-processor` folder run:
177178
- `nvm use` - to use correct Node version
178179
- `npm run install`
180+
- Create `.env` file with the next environment variables. Values for **Auth0 config** should be shared with you on the forum.<br>
181+
182+
```bash
183+
# Auth0 config
184+
AUTH0_URL=
185+
AUTH0_AUDIENCE=
186+
AUTH0_CLIENT_ID=
187+
AUTH0_CLIENT_SECRET=
188+
```
189+
190+
- Values from this file would be automatically used by many `npm` commands.
191+
- ⚠️ Never commit this file or its copy to the repository!
192+
179193
- `npm run start`
180194

181195
## NPM Commands
@@ -206,6 +220,7 @@ To be able to change and test `taas-es-processor` locally you can follow the nex
206220
| `npm run cov` | Code Coverage Report. |
207221
| `npm run migrate` | Run any migration files which haven't run yet. |
208222
| `npm run migrate:undo` | Revert most recent migration. |
223+
| `npm run demo-payment-scheduler` | Create 1000 Work Periods Payment records in with status "scheduled" and various "amount" |
209224
210225
## Import and Export data
211226

app-constants.js

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,24 @@ const ChallengeStatus = {
8686

8787
const WorkPeriodPaymentStatus = {
8888
COMPLETED: 'completed',
89-
CANCELLED: 'cancelled',
90-
SCHEDULED: 'scheduled'
89+
SCHEDULED: 'scheduled',
90+
IN_PROGRESS: 'in-progress',
91+
FAILED: 'failed',
92+
CANCELLED: 'cancelled'
93+
}
94+
95+
const PaymentProcessingSwitch = {
96+
ON: 'ON',
97+
OFF: 'OFF'
98+
}
99+
100+
const PaymentSchedulerStatus = {
101+
START_PROCESS: 'start-process',
102+
CREATE_CHALLENGE: 'create-challenge',
103+
ASSIGN_MEMBER: 'assign-member',
104+
ACTIVATE_CHALLENGE: 'activate-challenge',
105+
GET_USER_ID: 'get-userId',
106+
CLOSE_CHALLENGE: 'close-challenge'
91107
}
92108

93109
module.exports = {
@@ -96,5 +112,7 @@ module.exports = {
96112
Scopes,
97113
Interviews,
98114
ChallengeStatus,
99-
WorkPeriodPaymentStatus
115+
WorkPeriodPaymentStatus,
116+
PaymentSchedulerStatus,
117+
PaymentProcessingSwitch
100118
}

app.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const schedule = require('node-schedule')
1313
const logger = require('./src/common/logger')
1414
const eventHandlers = require('./src/eventHandlers')
1515
const interviewService = require('./src/services/InterviewService')
16+
const { processScheduler } = require('./src/services/PaymentSchedulerService')
1617

1718
// setup express app
1819
const app = express()
@@ -97,6 +98,9 @@ const server = app.listen(app.get('port'), () => {
9798
eventHandlers.init()
9899
// schedule updateCompletedInterviews to run every hour
99100
schedule.scheduleJob('0 0 * * * *', interviewService.updateCompletedInterviews)
101+
102+
// schedule payment processing
103+
schedule.scheduleJob(config.PAYMENT_PROCESSING.CRON, processScheduler)
100104
})
101105

102106
if (process.env.NODE_ENV === 'test') {

config/default.js

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ module.exports = {
140140
TAAS_ROLE_UPDATE_TOPIC: process.env.TAAS_ROLE_UPDATE_TOPIC || 'taas.role.update',
141141
// the delete role entity Kafka message topic
142142
TAAS_ROLE_DELETE_TOPIC: process.env.TAAS_ROLE_DELETE_TOPIC || 'taas.role.delete',
143+
// special kafka topics
144+
TAAS_ACTION_RETRY_TOPIC: process.env.TAAS_ACTION_RETRY_TOPIC || 'taas.action.retry',
143145

144146
// the Kafka message topic for sending email
145147
EMAIL_TOPIC: process.env.EMAIL_TOPIC || 'external.action.email',
@@ -173,5 +175,42 @@ module.exports = {
173175
// the minimum matching rate when searching roles by skills
174176
ROLE_MATCHING_RATE: process.env.ROLE_MATCHING_RATE || 0.70,
175177
// member groups representing Wipro or TopCoder employee
176-
INTERNAL_MEMBER_GROUPS: process.env.INTERNAL_MEMBER_GROUPS || ['20000000', '20000001', '20000003', '20000010', '20000015']
178+
INTERNAL_MEMBER_GROUPS: process.env.INTERNAL_MEMBER_GROUPS || ['20000000', '20000001', '20000003', '20000010', '20000015'],
179+
// Topcoder skills cache time in minutes
180+
TOPCODER_SKILLS_CACHE_TIME: process.env.TOPCODER_SKILLS_CACHE_TIME || 60,
181+
// payment scheduler config
182+
PAYMENT_PROCESSING: {
183+
// switch off actual API calls in Payment Scheduler
184+
SWITCH: process.env.PAYMENT_PROCESSING_SWITCH || 'OFF',
185+
// the payment scheduler cron config
186+
CRON: process.env.PAYMENT_PROCESSING_CRON || '0 */5 * * * *',
187+
// the number of records processed by one time
188+
BATCH_SIZE: parseInt(process.env.PAYMENT_PROCESSING_BATCH_SIZE || 50),
189+
// in-progress expired to determine whether a record has been processed abnormally, moment duration format
190+
IN_PROGRESS_EXPIRED: process.env.IN_PROGRESS_EXPIRED || 'PT1H',
191+
// the number of max retry config
192+
MAX_RETRY_COUNT: parseInt(process.env.PAYMENT_PROCESSING_MAX_RETRY_COUNT || 10),
193+
// the time of retry base delay, unit: ms
194+
RETRY_BASE_DELAY: parseInt(process.env.PAYMENT_PROCESSING_RETRY_BASE_DELAY || 100),
195+
// the time of retry max delay, unit: ms
196+
RETRY_MAX_DELAY: parseInt(process.env.PAYMENT_PROCESSING_RETRY_MAX_DELAY || 10000),
197+
// the max time of one request, unit: ms
198+
PER_REQUEST_MAX_TIME: parseInt(process.env.PAYMENT_PROCESSING_PER_REQUEST_MAX_TIME || 30000),
199+
// the max time of one payment record, unit: ms
200+
PER_PAYMENT_MAX_TIME: parseInt(process.env.PAYMENT_PROCESSING_PER_PAYMENT_MAX_TIME || 60000),
201+
// the max records of payment of a minute
202+
PER_MINUTE_PAYMENT_MAX_COUNT: parseInt(process.env.PAYMENT_PROCESSING_PER_MINUTE_PAYMENT_MAX_COUNT || 12),
203+
// the max requests of challenge of a minute
204+
PER_MINUTE_CHALLENGE_REQUEST_MAX_COUNT: parseInt(process.env.PAYMENT_PROCESSING_PER_MINUTE_CHALLENGE_REQUEST_MAX_COUNT || 60),
205+
// the max requests of resource of a minute
206+
PER_MINUTE_RESOURCE_REQUEST_MAX_COUNT: parseInt(process.env.PAYMENT_PROCESSING_PER_MINUTE_CHALLENGE_REQUEST_MAX_COUNT || 20),
207+
// the default step fix delay, unit: ms
208+
FIX_DELAY_STEP: parseInt(process.env.PAYMENT_PROCESSING_FIX_DELAY_STEP || 500),
209+
// the fix delay after step of create challenge, unit: ms
210+
FIX_DELAY_STEP_CREATE_CHALLENGE: parseInt(process.env.PAYMENT_PROCESSING_FIX_DELAY_STEP_CREATE_CHALLENGE || process.env.PAYMENT_PROCESSING_FIX_DELAY_STEP || 500),
211+
// the fix delay after step of assign member, unit: ms
212+
FIX_DELAY_STEP_ASSIGN_MEMBER: parseInt(process.env.PAYMENT_PROCESSING_FIX_DELAY_STEP_ASSIGN_MEMBER || process.env.PAYMENT_PROCESSING_FIX_DELAY_STEP || 500),
213+
// the fix delay after step of activate challenge, unit: ms
214+
FIX_DELAY_STEP_ACTIVATE_CHALLENGE: parseInt(process.env.PAYMENT_PROCESSING_FIX_DELAY_STEP_ACTIVATE_CHALLENGE || process.env.PAYMENT_PROCESSING_FIX_DELAY_STEP || 500)
215+
}
177216
}

0 commit comments

Comments
 (0)