@@ -4,6 +4,11 @@ const _ = require('lodash')
4
4
const helper = require ( '../src/common/helper' )
5
5
const { v4 : uuid } = require ( 'uuid' )
6
6
7
+ // maximum start date of resource bookings when populating work periods from existing resource bookings in migration script
8
+ const MAX_START_DATE = process . env . MAX_START_DATE || '2100-12-31'
9
+ // maximum end date of resource bookings when populating work periods from existing resource bookings in migration script
10
+ const MAX_END_DATE = process . env . MAX_END_DATE || '2100-12-31'
11
+
7
12
/*
8
13
* Populate WorkPeriods for ResourceBookings
9
14
*/
@@ -15,8 +20,8 @@ module.exports = {
15
20
try {
16
21
const resourceBookings = await ResourceBooking . findAll ( {
17
22
where : {
18
- start_date : { [ Op . lt ] : new Date ( config . MAX_START_DATE ) } ,
19
- end_date : { [ Op . lt ] : new Date ( config . MAX_END_DATE ) }
23
+ start_date : { [ Op . lt ] : new Date ( MAX_START_DATE ) } ,
24
+ end_date : { [ Op . lt ] : new Date ( MAX_END_DATE ) }
20
25
}
21
26
} )
22
27
if ( resourceBookings . length === 0 ) {
@@ -57,8 +62,8 @@ module.exports = {
57
62
const Op = Sequelize . Op
58
63
const resourceBookings = await ResourceBooking . findAll ( {
59
64
where : {
60
- start_date : { [ Op . lt ] : new Date ( config . MAX_START_DATE ) } ,
61
- end_date : { [ Op . lt ] : new Date ( config . MAX_END_DATE ) }
65
+ start_date : { [ Op . lt ] : new Date ( MAX_START_DATE ) } ,
66
+ end_date : { [ Op . lt ] : new Date ( MAX_END_DATE ) }
62
67
} ,
63
68
// include soft-deleted resourceBookings
64
69
paranoid : false
0 commit comments