File tree Expand file tree Collapse file tree 1 file changed +20
-8
lines changed
scripts/withdrawn-migration Expand file tree Collapse file tree 1 file changed +20
-8
lines changed Original file line number Diff line number Diff line change @@ -22,13 +22,25 @@ async function backup () {
22
22
23
23
for ( let i = 0 ; i < jobCandidates . length ; i ++ ) {
24
24
const jc = jobCandidates [ i ]
25
- const job = await Job . findById ( jc . jobId )
26
- const rb = await ResourceBooking . findOne ( {
27
- where : {
28
- userId : jc . userId ,
29
- jobId : jc . jobId
30
- }
31
- } )
25
+ let job = null
26
+ try {
27
+ job = await Job . findById ( jc . jobId )
28
+ } catch ( error ) {
29
+ // ignore the error
30
+ }
31
+ if ( ! job ) continue
32
+ let rb = null
33
+ try {
34
+ rb = await ResourceBooking . findOne ( {
35
+ where : {
36
+ userId : jc . userId ,
37
+ jobId : jc . jobId
38
+ }
39
+ } )
40
+ } catch ( error ) {
41
+ // ignore the error
42
+ }
43
+ if ( ! rb ) continue
32
44
let completed = false
33
45
if ( rb && rb . endDate ) {
34
46
completed = new Date ( rb . endDate ) < new Date ( ) && new Date ( rb . endDate ) . toDateString ( ) !== new Date ( ) . toDateString ( )
@@ -42,7 +54,7 @@ async function backup () {
42
54
where : filter
43
55
} )
44
56
if ( candidates && candidates . length > 0 ) {
45
- fs . writeFile ( filePath + ` jobcandidate-backup.json` , JSON . stringify (
57
+ fs . writeFile ( filePath + ' jobcandidate-backup.json' , JSON . stringify (
46
58
candidates
47
59
) , ( err ) => {
48
60
if ( ! err ) {
You can’t perform that action at this time.
0 commit comments