Closed
Description
Background
We already have some Jobs in Recruite CRM. As we are going to run our own TaaS App, we would like to import data from Recruit CRM to our TaaS App. We can export CSV files with jobs list from Recruit CRM. We would like to be able to import data from such files in DEV and PROD environment by running a script.
Task
- Create a script inside
scripts
directory. I should have it's own directory, which would contain:index.js
- the script itself to runREADME.md
- brief readme on how to run the script (which ENV vars to set and how to point CSV file)
- As we need to add data to both DB and ES, I guess the easier way would be make the script call TaaS API for creating jobs.
- We would have around
400
jobs in real data. - Script should get all params as ENV variables (for example M2M token config for calling TaaS API) or anything else
- CSV file path should be provided as an argument.
CSV file example:
DirectprojectId,projectId,externalId,title,startDate,endDate,numPositions,userHandle,jobid,customerRate,memberRate
24568,(dynamic load),0,taas-demo-job5,10/26/2020,1/29/2021,2,nkumartest,(dynamic load),20,10
24567,(dynamic load),1212,Dummy Description,10/20/2020,1/29/2021,2,pshah_manager,(dynamic load),150,100
24566,(dynamic load),23850272,33fromzaps330,2/21/2021,3/15/2021,7,nkumar2,(dynamic load),50,30
24565,(dynamic load),23843365,Designer,2/24/2021,3/30/2021,1,GunaK-TopCoder,(dynamic load),70,70
24564,(dynamic load),23836459,demo-dev-19janV4,1/20/2021,1/30/2021,1,nkumar1,(dynamic load),400,200
Script workflow
- Read a line from csv file
- If
externalId
is missing, log a warning about this and skip the line (goto 1). - From
DirectProjectID
getprojectId
by calling{TC_API}/projects/?directProjectId={DirectProjectID}
- We should create a job record in TaaS API from CSV file, only if it doesn't exists in TaaS API yet. To check it we have to use
externalId
and check if there is existent job with providedexternalId
:- If not, then create a job and note down created
jobId
(id
) - if a job with such
externalId
already exists, then don't create it, and just note down it'sjobId
(id
)
- If not, then create a job and note down created
- Get
userId
byuserHandle
field (via v5/users endpoint) - Now we have to create a ResourceBooking record for particular user and particular job if doesn't exists yet:
- If userid and jobId already exists at ResourceBooking then skip it (goto 1)
- otherwise create a resourcebooking using
jobId
anduserId
- Patch resourcebooking status based
csvfile.ENDDATE
. if today date > end date = "closed" else "assigned" - Delay for a second (config delay via env variable) and goto 1.
Notes
- The dates shared are for ResourceBooking start and end date, do not post this for Job creation.
- Validate for not null, if data missing alert for "field" cannot be null
- Dates has to be in mm/dd/yyyy format and validate for same.
- Provide a summary of total post, total successful loads, skips and failure. ( total post for jobs and total post for resourcebooking, provide total failed post for job and rb.)