summaryrefslogtreecommitdiff
path: root/flightquery.sh
diff options
context:
space:
mode:
authorAsa Venton <asav1410@gmail.com>2020-10-31 05:14:39 +0000
committerAsa Venton <asav1410@gmail.com>2020-10-31 05:14:39 +0000
commit7ed1d3da600703294d9b06cf2258c2813a89080e (patch)
tree38e178567c83524523dc0d8f9bf3e8346f4d5659 /flightquery.sh
parentea688057dbee3f8d280bfcb9b19bfe89945ab286 (diff)
Sort json in _arrivals and _departures by scheduled landing and takeoff respectively.
Diffstat (limited to 'flightquery.sh')
-rwxr-xr-xflightquery.sh8
1 files changed, 5 insertions, 3 deletions
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
}