@@ -4,6 +4,11 @@ const _ = require('lodash')
44const helper = require ( '../src/common/helper' )
55const { v4 : uuid } = require ( 'uuid' )
66
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+
712/*
813 * Populate WorkPeriods for ResourceBookings
914 */
@@ -15,8 +20,8 @@ module.exports = {
1520 try {
1621 const resourceBookings = await ResourceBooking . findAll ( {
1722 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 ) }
2025 }
2126 } )
2227 if ( resourceBookings . length === 0 ) {
@@ -57,8 +62,8 @@ module.exports = {
5762 const Op = Sequelize . Op
5863 const resourceBookings = await ResourceBooking . findAll ( {
5964 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 ) }
6267 } ,
6368 // include soft-deleted resourceBookings
6469 paranoid : false
0 commit comments