From 7ed1d3da600703294d9b06cf2258c2813a89080e Mon Sep 17 00:00:00 2001 From: Asa Venton Date: Sat, 31 Oct 2020 05:14:39 +0000 Subject: Sort json in _arrivals and _departures by scheduled landing and takeoff respectively. --- flightquery.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'flightquery.sh') diff --git a/flightquery.sh b/flightquery.sh index b725350..2382fa6 100755 --- a/flightquery.sh +++ b/flightquery.sh @@ -33,8 +33,9 @@ _getdata() { _arrivals() { _getdata + result=$(echo $result | jq '.data | sort_by(.arrival.scheduled)') # TODO: Sort by something (arrival time?), limit to a certin number of flights (X before current time and Y after?) and format on single line of output - for json in $(echo "${result}" | jq -r '.data[] | @base64') + for json in $(echo "${result}" | jq -r '.[] | @base64') do origin=$(_jq '.departure.airport') takeoffSched=$(_jq '.departure.scheduled') @@ -47,15 +48,16 @@ _arrivals() { _departures() { _getdata + result=$(echo $result | jq '.data | sort_by(.departure.scheduled)') # TODO: Sort by something (departure time?), limit to a certin number of flights (X before current time and Y after?) and format on single line of output - for json in $(echo "${result}" | jq -r '.data[] | @base64') + for json in $(echo "${result}" | jq -r '.[] | @base64') do destination=$(_jq '.arrival.airport') takeoffSched=$(_jq '.departure.scheduled') landingSched=$(_jq '.arrival.scheduled') airline=$(_jq '.airline.name') flightNumber=$(_jq '.flight.number') - echo "$airline $flightNumber destination: $destination Takeoff: $takeoffSched Landed: $landingSched" + echo "$airline $flightNumber Destination: $destination Takeoff: $takeoffSched Landed: $landingSched" done } -- cgit v1.2.3