Skip to content

Commit 1a3c098

Browse files
Merge pull request #452 from topcoder-platform/migrate-jobcandidates-scripts
Migrate jobcandidates scripts V4
2 parents 07e9218 + 6455cce commit 1a3c098

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

data/demo-data.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
"isApplicationPageActive": false,
8787
"minSalary": 100,
8888
"maxSalary": 200,
89-
"hoursPerWeek": 20,
89+
"hoursPerWeek": 90,
9090
"jobLocation": "Any location",
9191
"jobTimezone": "GMT",
9292
"currency": "USD",
@@ -833,9 +833,9 @@
833833
},
834834
{
835835
"id": "881a19de-2b0c-4bb9-b36a-4cb5e223bdb5",
836-
"jobId": "728ff056-63f6-4730-8a9f-3074acad8479",
836+
"jobId": "a8adb1f8-a6ee-48b1-8661-33bd851b726e",
837837
"userId": "a55fe1bc-1754-45fa-9adc-cf3d6d7c377a",
838-
"status": "open",
838+
"status": "placed",
839839
"externalId": "300234321",
840840
"resume": "http://example.com",
841841
"remark": "excellent",
@@ -1645,11 +1645,11 @@
16451645
{
16461646
"id": "c0a12936-77ef-46fa-8c75-6996339e79f6",
16471647
"projectId": 111,
1648-
"userId": "05e988b7-7d54-4c10-ada1-1a04870a88a8",
16491648
"jobId": "a8adb1f8-a6ee-48b1-8661-33bd851b726e",
1649+
"userId": "a55fe1bc-1754-45fa-9adc-cf3d6d7c377a",
16501650
"status": "placed",
16511651
"startDate": "2020-09-27",
1652-
"endDate": "2020-10-27",
1652+
"endDate": "2021-10-27",
16531653
"memberRate": 13.23,
16541654
"customerRate": 13,
16551655
"rateType": "hourly",

scripts/demo-email-notifications/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ async function resetNotificationRecords () {
2323
// reset coming up interview records
2424
localLogger.info('reset coming up interview records')
2525
const interview = await Interview.findById('976d23a9-5710-453f-99d9-f57a588bb610')
26-
const startTimestamp = moment().add(moment.duration(`PT1H`)).add('PT1M').toDate()
26+
const startTimestamp = moment().add(moment.duration('PT1H')).add('PT1M').toDate()
2727
await interview.update({ startTimestamp, duration: 30, status: Interviews.Status.Scheduled, guestNames: ['test1', 'test2'], hostName: 'hostName' })
2828

2929
// reset completed interview records

scripts/withdrawn-migration/backup.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ async function backup () {
2424
}
2525
})
2626
let summary = 0
27+
const processMapping = {}
2728
for (let i = 0; i < jobCandidates.length; i++) {
2829
const jc = jobCandidates[i]
30+
if (processMapping[jc.userId]) continue
2931
let job = null
3032
try {
3133
job = await Job.findById(jc.jobId)
@@ -60,17 +62,17 @@ async function backup () {
6062
where: filter
6163
})
6264
if (candidates && candidates.length > 0) {
63-
summary += candidates.length
64-
fs.writeFile(filePath + `jobcandidate-backup-${i+1}.json`, JSON.stringify(
65-
candidates
66-
), (err) => {
67-
if (!err) {
68-
logger.info({ component: `${currentStep} Sub`, message: `There are ${candidates.length} jobCandidates that need to be updated for userId: ${jc.userId}` })
69-
return
70-
}
65+
try {
66+
fs.writeFileSync(filePath + `jobcandidate-backup-${i + 1}.json`, JSON.stringify(
67+
candidates
68+
))
69+
logger.info({ component: `${currentStep} Sub`, message: `There are ${candidates.length} jobCandidates that need to be updated for userId: ${jc.userId}` })
70+
summary += candidates.length
71+
processMapping[jc.userId] = true
72+
} catch (err) {
7173
logger.error({ component: currentStep, message: err.message })
7274
process.exit(1)
73-
})
75+
}
7476
}
7577
}
7678
}

0 commit comments

Comments
 (0)