const operationIds = [ '2426751', '2434332', '2437824', '2441471', '2442525', '2444241', '2448226', '2450977', '2450978', '2452151', '2454255', '2455048', '2456857', '2459854', '2464152', '2427276', '257516', '253794', '255167', '2512213', '2517294', '2426410', '2426948', '2431358', '2431912', '2434469', '2436242', '2438333', '2437519', '2437520', '2443169', '2444553', '2440273', '2447842', '2445509', '2448178', '2445513', '2448657', '2448656', '2448658', '2452629', '2448659', '2448660', '2458555', '2448936', '2459573', '2448937', '2448938', '2461070', '2461023', '2448939', '2448941', '2448942', '2448943', '2448944', '2448945', '2465278', '2466056', '2466569', '2470605', '2471479', '252341', '253677', '256885', '2510564', '2510931', '2513296', '2516877', '2519324', '2522937', '2525602', '2512706', '2460117', '254894', '255872', '2467856', '2444103', '2470688', '2428718', '2432271', '2469884', '2440536', '2462825', '2468018', '2440535', '2462410', '2447292', '2464146', '2455744', '2443173', ]; const query = ` query GetTourCostBreakdown($operationId: String!) { tourCostBreakdown(operationId: $operationId) { tariffDescription tariffValidityPeriod servicePositions { value description variant } } } `; async function fetchCalculation(tourId: string) { try { const response = await fetch('http://localhost:3000/graphql', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ query, variables: { "operationId": tourId, }, }), }); if (!response.ok) { console.error( `failed to load calculation for ${tourId}: ${response.status}` ); return } const json = await response.json() return { einsatznummer: tourId, ...json.data.tourCostBreakdown, } } catch (error) {} } const promises = operationIds.map(id => fetchCalculation(id)); const results = await Promise.all(promises); await Deno.writeTextFile( "./tour_export.json", JSON.stringify(results, null, 2) ); export {}