Skip to content

Commit d2f669a

Browse files
committed
chore: move MAX dates to migration script from common config
1 parent 2c16aff commit d2f669a

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

config/default.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,5 @@ module.exports = {
135135
// the URL where TaaS App is hosted
136136
TAAS_APP_URL: process.env.TAAS_APP_URL || 'https://platform.topcoder-dev.com/taas/myteams',
137137
// default time zone for Work Periods
138-
WORK_PERIOD_TIME_ZONE: process.env.WORK_PERIOD_TIME_ZONE || 'America/New_York',
139-
// maximum start date of resource bookings when populating work periods from existing resource bookings in migration script
140-
MAX_START_DATE: process.env.MAX_START_DATE || '2100-12-31',
141-
// maximum end date of resource bookings when populating work periods from existing resource bookings in migration script
142-
MAX_END_DATE: process.env.MAX_END_DATE || '2100-12-31'
138+
WORK_PERIOD_TIME_ZONE: process.env.WORK_PERIOD_TIME_ZONE || 'America/New_York'
143139
}

migrations/2021-04-10-populate-work-periods-for-resource-bookings.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ const _ = require('lodash')
44
const helper = require('../src/common/helper')
55
const { 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

Comments
 (0)