Skip to content

Commit 481ccfc

Browse files
committed
upcoming job: use regex to set launchpad + timezone
1 parent 454ab9e commit 481ccfc

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

jobs/upcoming.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,17 @@ module.exports = async () => {
146146
// Add flight numbers to array to check for duplicates
147147
flightNumbers.push(baseFlightNumber + wikiIndex);
148148

149+
// Wiki launchpad matchers
150+
const slc40Pattern = /^.*SLC-40.*LC-39A|BC?.*$/i;
151+
const lc39aPattern = /^.*LC-39A.*SLC-40|BC?.*$/i;
152+
const slc4ePattern = /^.*SLC-4E.*$/i;
153+
const bcPattern = /^.*BC.*SLC-40|LC-39A?.*$/i;
154+
149155
// Calculate launch site depending on wiki manifest
150156
let launchpadId;
151157
let timezone;
152158
const launchpad = wikiLaunchpads[parseInt(wikiIndex, 10)];
153-
if (launchpad === 'SLC-40' || launchpad === 'SLC-40 / LC-39A' || launchpad === 'SLC-40 / BC' || launchpad === 'SLC-40, LC-39A') {
159+
if (slc40Pattern.test(launchpad)) {
154160
const launchpads = await got.post(`${SPACEX_API}/launchpads/query`, {
155161
json: {
156162
query: {
@@ -165,7 +171,7 @@ module.exports = async () => {
165171
});
166172
launchpadId = launchpads.docs[0].id;
167173
timezone = launchpads.docs[0].timezone;
168-
} else if (launchpad === 'LC-39A' || launchpad === 'LC-39A / BC' || launchpad === 'LC-39A / SLC-40') {
174+
} else if (lc39aPattern.test(launchpad)) {
169175
const launchpads = await got.post(`${SPACEX_API}/launchpads/query`, {
170176
json: {
171177
query: {
@@ -180,7 +186,7 @@ module.exports = async () => {
180186
});
181187
launchpadId = launchpads.docs[0].id;
182188
timezone = launchpads.docs[0].timezone;
183-
} else if (launchpad === 'SLC-4E') {
189+
} else if (slc4ePattern.test(launchpad)) {
184190
const launchpads = await got.post(`${SPACEX_API}/launchpads/query`, {
185191
json: {
186192
query: {
@@ -195,7 +201,7 @@ module.exports = async () => {
195201
});
196202
launchpadId = launchpads.docs[0].id;
197203
timezone = launchpads.docs[0].timezone;
198-
} else if (launchpad === 'BC' || launchpad === 'BC / LC-39A' || launchpad === 'BC / SLC-40') {
204+
} else if (bcPattern.test(launchpad)) {
199205
const launchpads = await got.post(`${SPACEX_API}/launchpads/query`, {
200206
json: {
201207
query: {

0 commit comments

Comments
 (0)