in dialogflow-prebuilt-agents/client_side_messenger/airline_support/airline_support.js [146:174]
function generateRandomFlightRoutes(
originCode, destinationCode, travelDate, durationMinutes,
timezoneDifferenceMinutes) {
const flightCount = 5;
const routes = [];
for (let i = 0; i < flightCount; i++) {
const stopCount = i > 3 ? getRandomInt(1, 2) : 0;
const route = generateRoute(
originCode, destinationCode, travelDate, stopCount, durationMinutes,
timezoneDifferenceMinutes);
if (!route) break;
routes.push(route);
}
// add cost tags
const prices = routes.map((route) => route.cost_usd);
prices.sort((a, b) => a - b);
const lowestPrice = prices[0];
const highestPrice = prices[prices.length - 1];
for (const route of routes) {
route.cost_tag = 'NONE';
if (route.cost_usd === lowestPrice) route.cost_tag = 'LOWEST';
if (route.cost_usd === highestPrice) route.cost_tag = 'HIGHEST';
}
return routes;
}