Skip to content

Commit 86b1b7c

Browse files
committed
fix: script to import job from RCRM
1 parent 3204533 commit 86b1b7c

File tree

5 files changed

+702
-668
lines changed

5 files changed

+702
-668
lines changed
Lines changed: 81 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,81 @@
1-
Recruit CRM Data Import
2-
===
3-
4-
# Configuration
5-
Configuration file is at `./scripts/recruit-crm-job-import/config.js`.
6-
7-
8-
# Usage
9-
``` bash
10-
node scripts/recruit-crm-job-import <pathname-to-a-csv-file>
11-
```
12-
13-
By default the script creates jobs and resource bookings via `TC_API`.
14-
# Example
15-
16-
Follow the README for Taas API to deploy Taas API locally and then point the script to the local API by running:
17-
18-
``` bash
19-
export RCRM_IMPORT_TAAS_API_URL=http://localhost:3000/api/v5
20-
node scripts/recruit-crm-job-import scripts/recruit-crm-job-import/example_data.csv | tee /tmp/report.txt
21-
```
22-
23-
The example output is:
24-
25-
``` bash
26-
DEBUG: processing line #1 - {"directProjectId":"24568","projectId":"(dynamic load)","externalId":"","title":"taas-demo-job5","startDate":"10/26/2020","endDate":"01/29/2021","numPositions":"2","userHandle":"nkumartest","jobid":"(dynamic load)","customerRate":"20","memberRate":"10","_lnum":1}
27-
WARN: #1 - externalId is missing
28-
DEBUG: processed line #1
29-
DEBUG: processing line #2 - {"directProjectId":"24568","projectId":"(dynamic load)","externalId":"0","title":"taas-demo-job5","startDate":"10/26/2020","endDate":"01/29/2021","numPositions":"2","userHandle":"not_found_handle","jobid":"(dynamic load)","customerRate":"20","memberRate":"10","_lnum":2}
30-
ERROR: #2 - handle: not_found_handle user not found
31-
DEBUG: processed line #2
32-
DEBUG: processing line #3 - {"directProjectId":"24568","projectId":"(dynamic load)","externalId":"0","title":"taas-demo-job5","startDate":"10/26/2020","endDate":"01/29/2021","numPositions":"2","userHandle":"nkumartest","jobid":"(dynamic load)","customerRate":"20","memberRate":"10","_lnum":3}
33-
DEBUG: userHandle: nkumartest userId: 57646ff9-1cd3-4d3c-88ba-eb09a395366c
34-
DEBUG: resourceBookingId: dc8b23d4-9987-4a7d-a587-2056283223de status: assigned
35-
INFO: #3 - id: 7c8ed989-35bf-4899-9c93-708630a7c63b job already exists; id: dc8b23d4-9987-4a7d-a587-2056283223de resource booking created; id: dc8b23d4-9987-4a7d-a587-2056283223de status: assigned resource booking updated
36-
DEBUG: processed line #3
37-
DEBUG: processing line #4 - {"directProjectId":"24567","projectId":"(dynamic load)","externalId":"1212","title":"Dummy Description","startDate":"10/20/2020","endDate":"01/29/2021","numPositions":"2","userHandle":"pshah_manager","jobid":"(dynamic load)","customerRate":"150","memberRate":"100","_lnum":4}
38-
DEBUG: userHandle: pshah_manager userId: a55fe1bc-1754-45fa-9adc-cf3d6d7c377a
39-
DEBUG: resourceBookingId: 708469fb-ead0-4fc3-bef7-1ef4dd041428 status: assigned
40-
INFO: #4 - id: f61da880-5295-40c2-b6db-21e6cdef93f9 job created; id: 708469fb-ead0-4fc3-bef7-1ef4dd041428 resource booking created; id: 708469fb-ead0-4fc3-bef7-1ef4dd041428 status: assigned resource booking updated
41-
DEBUG: processed line #4
42-
DEBUG: processing line #5 - {"directProjectId":"24566","projectId":"(dynamic load)","externalId":"23850272","title":"33fromzaps330","startDate":"02/21/2021","endDate":"03/15/2021","numPositions":"7","userHandle":"nkumar2","jobid":"(dynamic load)","customerRate":"50","memberRate":"30","_lnum":5}
43-
DEBUG: userHandle: nkumar2 userId: 4b00d029-c87b-47b2-bfe2-0ab80d8b5774
44-
DEBUG: resourceBookingId: 7870c30b-e511-48f2-8687-499ab116174f status: assigned
45-
INFO: #5 - id: 72dc0399-5e4b-4783-9a27-ea07a4ce99a7 job created; id: 7870c30b-e511-48f2-8687-499ab116174f resource booking created; id: 7870c30b-e511-48f2-8687-499ab116174f status: assigned resource booking updated
46-
DEBUG: processed line #5
47-
DEBUG: processing line #6 - {"directProjectId":"24565","projectId":"(dynamic load)","externalId":"23843365","title":"Designer","startDate":"02/24/2021","endDate":"03/30/2021","numPositions":"1","userHandle":"GunaK-TopCoder","jobid":"(dynamic load)","customerRate":"70","memberRate":"70","_lnum":6}
48-
DEBUG: userHandle: GunaK-TopCoder userId: 2bba34d5-20e4-46d6-bfc1-05736b17afbb
49-
DEBUG: resourceBookingId: b2e705d3-6864-4697-96bb-dc2a288755bc status: assigned
50-
INFO: #6 - id: 7ff0737e-958c-494e-8a5a-592ac1c5d4ff job created; id: b2e705d3-6864-4697-96bb-dc2a288755bc resource booking created; id: b2e705d3-6864-4697-96bb-dc2a288755bc status: assigned resource booking updated
51-
DEBUG: processed line #6
52-
DEBUG: processing line #7 - {"directProjectId":"24564","projectId":"(dynamic load)","externalId":"23836459","title":"demo-dev-19janV4","startDate":"01/20/2021","endDate":"01/30/2021","numPositions":"1","userHandle":"nkumar1","jobid":"(dynamic load)","customerRate":"400","memberRate":"200","_lnum":7}
53-
DEBUG: userHandle: nkumar1 userId: ab19a53b-0607-4a99-8bdd-f3b0cb552293
54-
DEBUG: resourceBookingId: 04299b4c-3f6e-4b3e-ae57-bf8232408cf9 status: assigned
55-
INFO: #7 - id: 73301ade-40ff-4103-bd50-37b8d2a98183 job created; id: 04299b4c-3f6e-4b3e-ae57-bf8232408cf9 resource booking created; id: 04299b4c-3f6e-4b3e-ae57-bf8232408cf9 status: assigned resource booking updated
56-
DEBUG: processed line #7
57-
INFO: === summary ===
58-
INFO: total: 7
59-
INFO: success: 5
60-
INFO: failure: 1
61-
INFO: skips: 1
62-
INFO: === summary ===
63-
INFO: done!
64-
```
65-
66-
To list all skipped lines:
67-
68-
``` bash
69-
cat /tmp/report.txt | grep 'WARN'
70-
```
71-
72-
To find out whether there are some users not found by user handles, run the following command:
73-
74-
``` bash
75-
cat /tmp/report.txt | grep 'ERROR' | grep 'user not found'
76-
```
1+
Recruit CRM Data Import
2+
===
3+
4+
# Configuration
5+
Configuration file is at `./scripts/recruit-crm-job-import/config.js`.
6+
7+
8+
# Usage
9+
``` bash
10+
node scripts/recruit-crm-job-import <pathname-to-a-csv-file>
11+
```
12+
13+
By default the script creates jobs and resource bookings via `TC_API`.
14+
# Example
15+
16+
Follow the README for Taas API to deploy Taas API locally and then point the script to the local API by running:
17+
18+
``` bash
19+
export RCRM_IMPORT_CONFIG_NAMESAPCE=RCRM_IMPORT_
20+
export RCRM_IMPORT_TAAS_API_URL=http://localhost:3000/api/v5
21+
node scripts/recruit-crm-job-import scripts/recruit-crm-job-import/example_data.csv | tee /tmp/report.txt
22+
```
23+
24+
The example output is:
25+
26+
``` bash
27+
DEBUG: processing line #1 - {"directProjectId":"24568","projectId":"(dynamic load)","externalId":"","title":"taas-demo-job5","startDate":"10/26/2020","endDate":"01/29/2021","numPositions":"2","userHandle":"nkumartest","jobid":"(dynamic load)","customerRate":"20","memberRate":"10","_lnum":1}
28+
WARN: #1 - externalId is missing
29+
DEBUG: processed line #1
30+
DEBUG: processing line #2 - {"directProjectId":"24568","projectId":"(dynamic load)","externalId":"0","title":"taas-demo-job5","startDate":"10/26/2020","endDate":"01/29/2021","numPositions":"2","userHandle":"not_found_handle","jobid":"(dynamic load)","customerRate":"20","memberRate":"10","_lnum":2}
31+
ERROR: #2 - id: 51ce2216-0dee-4dcf-bf7d-79f862e8d63c job created; handle: not_found_handle user not found
32+
DEBUG: processed line #2
33+
DEBUG: processing line #3 - {"directProjectId":"24568","projectId":"(dynamic load)","externalId":"0","title":"taas-demo-job5","startDate":"10/26/2020","endDate":"01/29/2021","numPositions":"2","userHandle":"nkumartest","jobid":"(dynamic load)","customerRate":"20","memberRate":"10","_lnum":3}
34+
DEBUG: userHandle: nkumartest userId: 57646ff9-1cd3-4d3c-88ba-eb09a395366c
35+
INFO: #3 - id: 51ce2216-0dee-4dcf-bf7d-79f862e8d63c externalId: 0 job already exists; id: d49d2fbd-ba11-49dc-8eaa-5afafa7e993f resource booking created
36+
DEBUG: processed line #3
37+
DEBUG: processing line #4 - {"directProjectId":"24567","projectId":"(dynamic load)","externalId":"1212","title":"Dummy Description","startDate":"10/20/2020","endDate":"01/29/2021","numPositions":"2","userHandle":"pshah_manager","jobid":"(dynamic load)","customerRate":"150","memberRate":"100","_lnum":4}
38+
DEBUG: userHandle: pshah_manager userId: a55fe1bc-1754-45fa-9adc-cf3d6d7c377a
39+
INFO: #4 - id: e0267551-24fe-48b5-9605-719852901de2 job created; id: f6285f03-056d-446f-a69b-6d275a97d68a resource booking created
40+
DEBUG: processed line #4
41+
DEBUG: processing line #5 - {"directProjectId":"24566","projectId":"(dynamic load)","externalId":"23850272","title":"33fromzaps330","startDate":"02/21/2021","endDate":"03/15/2021","numPositions":"7","userHandle":"nkumar2","jobid":"(dynamic load)","customerRate":"50","memberRate":"30","_lnum":5}
42+
DEBUG: userHandle: nkumar2 userId: 4b00d029-c87b-47b2-bfe2-0ab80d8b5774
43+
INFO: #5 - id: cd94784c-432d-4c46-b860-04a89e7b1099 job created; id: 98604c13-c6f3-4203-b74f-db376e9f02e4 resource booking created
44+
DEBUG: processed line #5
45+
DEBUG: processing line #6 - {"directProjectId":"24565","projectId":"(dynamic load)","externalId":"23843365","title":"Designer","startDate":"02/24/2021","endDate":"03/30/2021","numPositions":"1","userHandle":"GunaK-TopCoder","jobid":"(dynamic load)","customerRate":"70","memberRate":"70","_lnum":6}
46+
DEBUG: userHandle: GunaK-TopCoder userId: 2bba34d5-20e4-46d6-bfc1-05736b17afbb
47+
INFO: #6 - id: 49883150-59c2-4e5b-b5c3-aaf6d11d0da2 job created; id: 5505b6b5-050c-421c-893f-b862b1a08092 resource booking created
48+
DEBUG: processed line #6
49+
DEBUG: processing line #7 - {"directProjectId":"24564","projectId":"(dynamic load)","externalId":"23836459","title":"demo-dev-19janV4","startDate":"01/20/2021","endDate":"01/30/2021","numPositions":"1","userHandle":"nkumar1","jobid":"(dynamic load)","customerRate":"400","memberRate":"200","_lnum":7}
50+
DEBUG: userHandle: nkumar1 userId: ab19a53b-0607-4a99-8bdd-f3b0cb552293
51+
INFO: #7 - id: b03dc641-d6be-4a15-9c86-ef38f0e20c28 job created; id: 8e332107-453b-4ec5-b934-902c829e73a2 resource booking created
52+
DEBUG: processed line #7
53+
INFO: === summary ===
54+
INFO: total: 7
55+
INFO: success: 5
56+
INFO: failure: 1
57+
INFO: skips: 1
58+
INFO: jobs created: 5
59+
INFO: resource bookings created: 5
60+
INFO: jobs already exist: 1
61+
INFO: resource bookings already exist: 0
62+
INFO: validation errors: 0
63+
INFO: user not found: 1
64+
INFO: external id missing: 1
65+
INFO: request error: 0
66+
INFO: internal error: 0
67+
INFO: === summary ===
68+
INFO: done!
69+
```
70+
71+
To list all skipped lines:
72+
73+
``` bash
74+
cat /tmp/report.txt | grep 'WARN'
75+
```
76+
77+
To find out whether there are some users not found by user handles, run the following command:
78+
79+
``` bash
80+
cat /tmp/report.txt | grep 'ERROR' | grep 'user not found'
81+
```

0 commit comments

Comments
 (0)