Skip to content

Commit 97866e2

Browse files
committed
role endpoint added
1 parent 87ede16 commit 97866e2

17 files changed

+309
-14
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ The following parameters can be set in config files or in env variables:
3838
- `topics.TAAS_INTERVIEW_REQUEST_TOPIC`: the request interview entity Kafka message topic
3939
- `topics.TAAS_INTERVIEW_UPDATE_TOPIC`: the update interview entity Kafka message topic
4040
- `topics.TAAS_INTERVIEW_BULK_UPDATE_TOPIC`: the bulk update interview entity Kafka message topic
41+
- `topics.TAAS_ROLE_CREATE_TOPIC`: the create role entity Kafka message topic
42+
- `topics.TAAS_ROLE_UPDATE_TOPIC`: the update role entity Kafka message topic
43+
- `topics.TAAS_ROLE_DELETE_TOPIC`: the delete role entity Kafka message topic
4144
- `esConfig.HOST`: Elasticsearch host
4245
- `esConfig.AWS_REGION`: The Amazon region to use when using AWS Elasticsearch service
4346
- `esConfig.ELASTICCLOUD.id`: The elastic cloud id, if your elasticsearch instance is hosted on elastic cloud. DO NOT provide a value for ES_HOST if you are using this
@@ -46,6 +49,7 @@ The following parameters can be set in config files or in env variables:
4649
- `esConfig.ES_INDEX_JOB`: the index name for job
4750
- `esConfig.ES_INDEX_JOB_CANDIDATE`: the index name for job candidate
4851
- `esConfig.ES_INDEX_RESOURCE_BOOKING`: the index name for resource booking
52+
- `esConfig.ES_INDEX_ROLE`: the index name for role
4953

5054
- `auth0.AUTH0_URL`: Auth0 URL, used to get TC M2M token
5155
- `auth0.AUTH0_AUDIENCE`: Auth0 audience, used to get TC M2M token

VERIFICATION.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Create documents in ES
44

5-
- Run the following commands to create `Job`, `JobCandidate`, `Interview`, `ResourceBooking`, `WorkPeriod`, `WorkPeriodPayment` documents in ES.
5+
- Run the following commands to create `Job`, `JobCandidate`, `Interview`, `ResourceBooking`, `WorkPeriod`, `WorkPeriodPayment`, `Role` documents in ES.
66

77
``` bash
88
# for Job
@@ -17,12 +17,14 @@
1717
docker exec -i taas-es-processor_kafka /opt/kafka/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic taas.workperiod.create < test/messages/taas.workperiod.create.event.json
1818
# for WorkPeriodPayment
1919
docker exec -i taas-es-processor_kafka /opt/kafka/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic taas.workperiodpayment.create < test/messages/taas.workperiodpayment.create.event.json
20+
# for Role
21+
docker exec -i taas-es-processor_kafka /opt/kafka/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic taas.role.requested < test/messages/taas.role.create.event.json
2022
```
2123

2224
- Run `npm run view-data <model-name-here>` to see if documents were created.
2325

2426
## Update documents in ES
25-
- Run the following commands to update `Job`, `JobCandidate`, `Interview`, `ResourceBooking`, `WorkPeriod`, `WorkPeriodPayment` documents in ES.
27+
- Run the following commands to update `Job`, `JobCandidate`, `Interview`, `ResourceBooking`, `WorkPeriod`, `WorkPeriodPayment`, `Role` documents in ES.
2628

2729
``` bash
2830
# for Job
@@ -37,12 +39,14 @@
3739
docker exec -i taas-es-processor_kafka /opt/kafka/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic taas.workperiod.update < test/messages/taas.workperiod.update.event.json
3840
# for WorkPeriodPayment
3941
docker exec -i taas-es-processor_kafka /opt/kafka/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic taas.workperiodpayment.update < test/messages/taas.workperiodpayment.update.event.json
42+
# for Role
43+
docker exec -i taas-es-processor_kafka /opt/kafka/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic taas.role.update < test/messages/taas.role.update.event.json
4044
```
4145

4246
- Run `npm run view-data <model-name-here>` to see if documents were updated.
4347

4448
## Delete documents in ES
45-
- Run the following commands to delete `Job`, `JobCandidate`, `ResourceBooking`, `WorkPeriod` documents in ES.
49+
- Run the following commands to delete `Job`, `JobCandidate`, `ResourceBooking`, `WorkPeriod`, `Role` documents in ES.
4650

4751
``` bash
4852
# for Job
@@ -53,6 +57,8 @@
5357
docker exec -i taas-es-processor_kafka /opt/kafka/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic taas.resourcebooking.delete < test/messages/taas.resourcebooking.delete.event.json
5458
# for WorkPeriod
5559
docker exec -i taas-es-processor_kafka /opt/kafka/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic taas.workperiod.delete < test/messages/taas.workperiod.delete.event.json
60+
# for Role
61+
docker exec -i taas-es-processor_kafka /opt/kafka/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic taas.role.delete < test/messages/taas.role.delete.event.json
5662
```
5763

5864
- Run `npm run view-data <model-name-here>` to see if documents were deleted.

config/default.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ module.exports = {
3838
// topics for interview service
3939
TAAS_INTERVIEW_REQUEST_TOPIC: process.env.TAAS_INTERVIEW_REQUEST_TOPIC || 'taas.interview.requested',
4040
TAAS_INTERVIEW_UPDATE_TOPIC: process.env.TAAS_INTERVIEW_UPDATE_TOPIC || 'taas.interview.update',
41-
TAAS_INTERVIEW_BULK_UPDATE_TOPIC: process.env.TAAS_INTERVIEW_BULK_UPDATE_TOPIC || 'taas.interview.bulkUpdate'
41+
TAAS_INTERVIEW_BULK_UPDATE_TOPIC: process.env.TAAS_INTERVIEW_BULK_UPDATE_TOPIC || 'taas.interview.bulkUpdate',
42+
// topics for role service
43+
TAAS_ROLE_CREATE_TOPIC: process.env.TAAS_ROLE_CREATE_TOPIC || 'taas.role.requested',
44+
TAAS_ROLE_UPDATE_TOPIC: process.env.TAAS_ROLE_UPDATE_TOPIC || 'taas.role.update',
45+
TAAS_ROLE_DELETE_TOPIC: process.env.TAAS_ROLE_DELETE_TOPIC || 'taas.role.delete'
4246
},
4347

4448
esConfig: {
@@ -54,7 +58,8 @@ module.exports = {
5458

5559
ES_INDEX_JOB: process.env.ES_INDEX_JOB || 'job',
5660
ES_INDEX_JOB_CANDIDATE: process.env.ES_INDEX_JOB_CANDIDATE || 'job_candidate',
57-
ES_INDEX_RESOURCE_BOOKING: process.env.ES_INDEX_RESOURCE_BOOKING || 'resource_booking'
61+
ES_INDEX_RESOURCE_BOOKING: process.env.ES_INDEX_RESOURCE_BOOKING || 'resource_booking',
62+
ES_INDEX_ROLE: process.env.ES_INDEX_ROLE || 'role'
5863
},
5964

6065
auth0: {

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const ResourceBookingProcessorService = require('./services/ResourceBookingProce
1515
const WorkPeriodProcessorService = require('./services/WorkPeriodProcessorService')
1616
const InterviewProcessorService = require('./services/InterviewProcessorService')
1717
const WorkPeriodPaymentProcessorService = require('./services/WorkPeriodPaymentProcessorService')
18+
const RoleProcessorService = require('./services/RoleProcessorService')
1819
const Mutex = require('async-mutex').Mutex
1920
const events = require('events')
2021

@@ -52,7 +53,11 @@ const topicServiceMapping = {
5253
// interview
5354
[config.topics.TAAS_INTERVIEW_REQUEST_TOPIC]: InterviewProcessorService.processRequestInterview,
5455
[config.topics.TAAS_INTERVIEW_UPDATE_TOPIC]: InterviewProcessorService.processUpdateInterview,
55-
[config.topics.TAAS_INTERVIEW_BULK_UPDATE_TOPIC]: InterviewProcessorService.processBulkUpdateInterviews
56+
[config.topics.TAAS_INTERVIEW_BULK_UPDATE_TOPIC]: InterviewProcessorService.processBulkUpdateInterviews,
57+
// role
58+
[config.topics.TAAS_ROLE_CREATE_TOPIC]: RoleProcessorService.processCreate,
59+
[config.topics.TAAS_ROLE_UPDATE_TOPIC]: RoleProcessorService.processUpdate,
60+
[config.topics.TAAS_ROLE_DELETE_TOPIC]: RoleProcessorService.processDelete
5661
}
5762

5863
// Start kafka consumer

src/bootstrap.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Joi.workPeriodPaymentStatus = () => Joi.string().valid('completed', 'cancelled')
2323
// See https://joi.dev/api/?v=17.3.0#string fro details why it's like this.
2424
// In many cases we would like to allow empty string to make it easier to create UI for editing data.
2525
Joi.stringAllowEmpty = () => Joi.string().allow('')
26+
Joi.smallint = () => Joi.number().min(-32768).max(32767)
2627

2728
const zapierSwitch = Joi.string().label('ZAPIER_SWITCH').valid(...Object.values(constants.Zapier.Switch))
2829

src/scripts/createIndex.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ async function createIndex () {
2828
skills: { type: 'keyword' },
2929
status: { type: 'keyword' },
3030
isApplicationPageActive: { type: 'boolean' },
31+
roleIds: { type: 'keyword' },
3132
createdAt: { type: 'date' },
3233
createdBy: { type: 'keyword' },
3334
updatedAt: { type: 'date' },
@@ -140,6 +141,39 @@ async function createIndex () {
140141
}
141142
}
142143
}
144+
},
145+
{ index: config.get('esConfig.ES_INDEX_ROLE'),
146+
body: {
147+
mappings: {
148+
properties: {
149+
name: { type: 'keyword' },
150+
description: { type: 'keyword' },
151+
listOfSkills: { type: 'keyword' },
152+
rates: {
153+
properties: {
154+
global: { type: 'integer' },
155+
inCountry: { type: 'integer' },
156+
offShore: { type: 'integer' },
157+
rate30Global: { type: 'integer' },
158+
rate30InCountry: { type: 'integer' },
159+
rate30OffShore: { type: 'integer' },
160+
rate20Global: { type: 'integer' },
161+
rate20InCountry: { type: 'integer' },
162+
rate20OffShore: { type: 'integer' }
163+
}
164+
},
165+
numberOfMembers: { type: 'integer' },
166+
numberOfMembersAvailable: { type: 'integer' },
167+
imageUrl: { type: 'keyword' },
168+
timeToCandidate: { type: 'integer' },
169+
timeToInterview: { type: 'integer' },
170+
createdAt: { type: 'date' },
171+
createdBy: { type: 'keyword' },
172+
updatedAt: { type: 'date' },
173+
updatedBy: { type: 'keyword' }
174+
}
175+
}
176+
}
143177
}
144178
]
145179

src/scripts/deleteIndex.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ async function deleteIndex () {
1111
const esClient = helper.getESClient()
1212
const indices = [config.get('esConfig.ES_INDEX_JOB'),
1313
config.get('esConfig.ES_INDEX_JOB_CANDIDATE'),
14-
config.get('esConfig.ES_INDEX_RESOURCE_BOOKING')]
14+
config.get('esConfig.ES_INDEX_RESOURCE_BOOKING'),
15+
config.get('esConfig.ES_INDEX_ROLE')]
1516
for (const index of indices) {
1617
await esClient.indices.delete({
1718
index

src/scripts/view-data.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ const esClient = helper.getESClient()
1111
const modelIndexMapping = {
1212
Job: 'ES_INDEX_JOB',
1313
JobCandidate: 'ES_INDEX_JOB_CANDIDATE',
14-
ResourceBooking: 'ES_INDEX_RESOURCE_BOOKING'
14+
ResourceBooking: 'ES_INDEX_RESOURCE_BOOKING',
15+
Role: 'ES_INDEX_ROLE'
1516
}
1617

1718
async function showESData () {

src/services/JobProcessorService.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ processCreate.schema = {
8383
updatedAt: Joi.date().allow(null),
8484
updatedBy: Joi.string().uuid().allow(null),
8585
status: Joi.jobStatus().required(),
86-
isApplicationPageActive: Joi.boolean().required()
86+
isApplicationPageActive: Joi.boolean().required(),
87+
roleIds: Joi.array().items(Joi.string().uuid().required()).allow(null)
8788
}).required()
8889
}).required(),
8990
transactionId: Joi.string().required()

0 commit comments

Comments
 (0)