Skip to content

Commit

Permalink
Fixed prettier and eslint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jacoblurie29 committed Jan 14, 2024
1 parent eac0c3c commit dec39fb
Show file tree
Hide file tree
Showing 4 changed files with 189 additions and 191 deletions.
35 changes: 18 additions & 17 deletions src/controllers/TestControllers/retrievePassengers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable autofix/no-unused-vars */
/* eslint-disable @typescript-eslint/no-unused-vars */
import Airtable from 'airtable';
import dotenv from 'dotenv';
import type { FieldSet, Record } from 'airtable';
Expand All @@ -12,8 +10,7 @@ export const retrievePassengers = async (req: Request, res: Response) => {
console.log(process.env.AIRTABLE_API_KEY);

const base = new Airtable({
apiKey:
process.env.AIRTABLE_API_KEY || "",
apiKey: process.env.AIRTABLE_API_KEY || '',
}).base('appwPsfAb6U8CV3mf');

base('Flight Requests (Trips)')
Expand All @@ -24,25 +21,29 @@ export const retrievePassengers = async (req: Request, res: Response) => {
})
.firstPage(async function (err, records) {
if (err) {
console.error(err);
return;
console.error(err);
return;
}
if (records) {
const flightLegs = records.map(record => record.fields["Flight Legs"] !== undefined ? record.fields["Flight Legs"] : []) as string[][];
console.log('Retrieved Flight Leg IDs', flightLegs);

try {

const flightLegs = records.map(record =>
record.fields['Flight Legs'] !== undefined
? record.fields['Flight Legs']
: []
) as string[][];
console.log('Retrieved Flight Leg IDs', flightLegs);

try {
const trips = [] as Record<FieldSet>[][];
const promises = flightLegs.map(async trip => {
const flightLegsForTrip = [] as Record<FieldSet>[];
const tripPromises = trip.map(async flightLegId => {
const flightLegRecord = await base('Flight Legs').find(flightLegId?.toString() || ''); // Replace with your actual table name
const flightLegRecord = await base('Flight Legs').find(
flightLegId?.toString() || ''
); // Replace with your actual table name
flightLegsForTrip.push(flightLegRecord);
});
await Promise.all(tripPromises);
trips.push(flightLegsForTrip);

});

await Promise.all(promises);
Expand All @@ -51,9 +52,9 @@ export const retrievePassengers = async (req: Request, res: Response) => {

// Send the response or do further processing
res.status(200).send(trips);
} catch(err) {
console.error(err);
}
} catch (err) {
console.error(err);
}
}
});
});
};
145 changes: 72 additions & 73 deletions src/data/constants.ts
Original file line number Diff line number Diff line change
@@ -1,74 +1,73 @@
export const AIRLINES = [
"AA - American Airlines",
"AC - Air Canada",
"AE - American Eagle",
"AF - Air France",
"AG - Allegiant",
"AI - Air India",
"AK - Alaska",
"AL - Aer Lingus",
"AM - AeroMexico",
"AN - Air New Zealand",
"AO - Aeroflot",
"AR - Air Transat",
"AS - Air Serbia",
"AT - AirTran",
"ATA - American Trans Air",
"AU - Austrian Airlines",
"AV - Avianca",
"AW - America West",
"BA - British Airways",
"BH - Bahamasair",
"BS - Big Sky",
"CA - Corporate Airlines",
"CM - Com-Air",
"CN - Canadian Airlines",
"CO - Continental",
"CP - Copa Airlines",
"DA - Domodedovo Airlines",
"DL - Delta",
"EJ - Express Jet",
"EK - Emirates",
"FT - Frontier",
"GA - Grenadine Air Alliance",
"GL - Great Lakes",
"HA - Horizon Airlines",
"HI - Hawaiian Airlines",
"IA - Island Air",
"IC - Iceland Air",
"JB - JetBlue Airways",
"KLM - KLM Royal Dutch Airlines",
"LH - Lufhansa",
"LT - Liat Airlines",
"ME - Midway",
"MS - Mesaba",
"MU - Mustique Airways",
"MW - Midwest",
"MX - Mexicana",
"NA - National",
"NW - Northwest",
"OC - One Caribbean",
"QA - Qantas",
"RA - Ravn Alaska",
"SA - South African",
"SC - SunCountry",
"SK - Skywest",
"SM - Skyway",
"SN - Scandinavian",
"SP - Spirit",
"SVG - SVG Air",
"SW - Southwest",
"TA - Tropic Air",
"TK - Turkish Airlines",
"TWA - TransWorld Air",
"UN - United",
"US - US Airways",
"VA - Vanguard",
"VG - Virgin America",
"VL - Volaris Airlines",
"WJ - West Jet",
"US - US Aiways",
"SAE - Southern Airways Express",
"Qatar Airways",
];

'AA - American Airlines',
'AC - Air Canada',
'AE - American Eagle',
'AF - Air France',
'AG - Allegiant',
'AI - Air India',
'AK - Alaska',
'AL - Aer Lingus',
'AM - AeroMexico',
'AN - Air New Zealand',
'AO - Aeroflot',
'AR - Air Transat',
'AS - Air Serbia',
'AT - AirTran',
'ATA - American Trans Air',
'AU - Austrian Airlines',
'AV - Avianca',
'AW - America West',
'BA - British Airways',
'BH - Bahamasair',
'BS - Big Sky',
'CA - Corporate Airlines',
'CM - Com-Air',
'CN - Canadian Airlines',
'CO - Continental',
'CP - Copa Airlines',
'DA - Domodedovo Airlines',
'DL - Delta',
'EJ - Express Jet',
'EK - Emirates',
'FT - Frontier',
'GA - Grenadine Air Alliance',
'GL - Great Lakes',
'HA - Horizon Airlines',
'HI - Hawaiian Airlines',
'IA - Island Air',
'IC - Iceland Air',
'JB - JetBlue Airways',
'KLM - KLM Royal Dutch Airlines',
'LH - Lufhansa',
'LT - Liat Airlines',
'ME - Midway',
'MS - Mesaba',
'MU - Mustique Airways',
'MW - Midwest',
'MX - Mexicana',
'NA - National',
'NW - Northwest',
'OC - One Caribbean',
'QA - Qantas',
'RA - Ravn Alaska',
'SA - South African',
'SC - SunCountry',
'SK - Skywest',
'SM - Skyway',
'SN - Scandinavian',
'SP - Spirit',
'SVG - SVG Air',
'SW - Southwest',
'TA - Tropic Air',
'TK - Turkish Airlines',
'TWA - TransWorld Air',
'UN - United',
'US - US Airways',
'VA - Vanguard',
'VG - Virgin America',
'VL - Volaris Airlines',
'WJ - West Jet',
'US - US Aiways',
'SAE - Southern Airways Express',
'Qatar Airways',
];
107 changes: 53 additions & 54 deletions src/interfaces/flight-leg.interface.ts
Original file line number Diff line number Diff line change
@@ -1,56 +1,55 @@
export interface FlightLegData {
id: string;
createdTime: string;
fields: {
Status: string;
Airline: string;
"BL - Departure Airport": string;
"Departure Date/Time": string;
"BL - Arrival Airport": string;
"Arrival Date/Time": string;
"Nautical Miles": number;
PUR: number;
"BL - # of PAX": number;
"BL - Treatment Type": string;
"BL - Site 1": string;
Passengers: string[];
"Departure Airport": string;
"Arrival Airport": string;
"BL - Site 1 Links": string[];
"Leg ID": string;
"Leg Type": string;
"# of Linked PAX": number;
"# of PAX": number;
"Total Miles": number;
"Passenger Names": string | string[];
"Total Cost": number;
"Cost per PAX": number;
"AirTable Record ID": string;
"Request AirTable Record ID": string[];
"Passenger AirTable Record IDs": string | string[];
"Log Airline Credit": {
label: string;
url: string;
};
"Creation Date": string;
"Patient Name": string[];
"State (from Passengers)": string[];
"State (from Departure Airport)": string[];
"State (from Arrival Airport)": string[];
"State (from Passengers) 2": string[];
"State (from Departure Airport) 2": string[];
"Date of Birth (from Passengers)": string[];
"Patient Latest Trip": string[];
"Is Latest Trip": string;
"Home Phone (from Passengers)": string[];
"Street (from Passengers)": string[];
City: string[];
"State (from Passengers) 3": string[];
"Zip (from Passengers)": string[];
"Diagnosis (from Passengers)": string[];
"Date of Birth (from Passengers) 2": string[];
"TS City, State (from Treatment Site Totals 2) (from Passengers)": string[];
"48 Hours After Flight": string;
id: string;
createdTime: string;
fields: {
Status: string;
Airline: string;
'BL - Departure Airport': string;
'Departure Date/Time': string;
'BL - Arrival Airport': string;
'Arrival Date/Time': string;
'Nautical Miles': number;
PUR: number;
'BL - # of PAX': number;
'BL - Treatment Type': string;
'BL - Site 1': string;
Passengers: string[];
'Departure Airport': string;
'Arrival Airport': string;
'BL - Site 1 Links': string[];
'Leg ID': string;
'Leg Type': string;
'# of Linked PAX': number;
'# of PAX': number;
'Total Miles': number;
'Passenger Names': string | string[];
'Total Cost': number;
'Cost per PAX': number;
'AirTable Record ID': string;
'Request AirTable Record ID': string[];
'Passenger AirTable Record IDs': string | string[];
'Log Airline Credit': {
label: string;
url: string;
};
}

'Creation Date': string;
'Patient Name': string[];
'State (from Passengers)': string[];
'State (from Departure Airport)': string[];
'State (from Arrival Airport)': string[];
'State (from Passengers) 2': string[];
'State (from Departure Airport) 2': string[];
'Date of Birth (from Passengers)': string[];
'Patient Latest Trip': string[];
'Is Latest Trip': string;
'Home Phone (from Passengers)': string[];
'Street (from Passengers)': string[];
City: string[];
'State (from Passengers) 3': string[];
'Zip (from Passengers)': string[];
'Diagnosis (from Passengers)': string[];
'Date of Birth (from Passengers) 2': string[];
'TS City, State (from Treatment Site Totals 2) (from Passengers)': string[];
'48 Hours After Flight': string;
};
}
Loading

0 comments on commit dec39fb

Please sign in to comment.