I’m trying to create a BusWatch type piston that calls the Transport for London API and then tells me how long until the next couple of busses arrive. The problem is that the bus stop I’m looking at has more than one bus route but the response lists all of one bus route then all of the next so not necessarily in the order they will arrive. I would like to be able to re-order the data so that I can get the arrival time (in seconds) of the next two busses and then use a bit of maths to get it into minutes & seconds format.
Count of busses on approach - [7]
Bus Lines on approach - [E2, E2, E7, E7, E8, E8, E8]
Bus arrival times on approach - [783, 1296, 449, 1233, 518, 1485, 1004]
One of the things I’ve been trying is simply to get the min() value from the third list so that I can re-order them and then some how apply the same re-ordering to the Bus Lines
2) What is the expected behaviour?
to sort the data but not entirely sure how yet.
3) What is happening/not happening?
Am unable to even get the min() value from a list generated from the $response data
16/08/2022, 14:54:56 +268ms
+3ms ╔Received event [27Curzon].wc_async_reply = httpRequest with a delay of 0ms, canQueue: true, calledMyself: false
+11ms ║RunTime initialize > 10 LockT > 1ms > r9T > 1ms > pistonT > 0ms (first state access 8 4 6)
+13ms ║Runtime (7373 bytes) initialized in 1ms (v0.3.114.20220418_HE)
+33ms ║╔Execution stage started
+44ms ║║9
+46ms ║║Executed virtual command log (2ms)
+51ms ║║E2
+52ms ║║Executed virtual command log (2ms)
+57ms ║║[E2, E2, E2, E7, E7, E8, E8, E8, E8]
+59ms ║║Executed virtual command log (2ms)
+63ms ║║[1617, 1101, 420, 1307, 523, 775, 1734, 1254, 294]
+65ms ║║Executed virtual command log (2ms)
+73ms ║║[1617, 1101, 420, 1307, 523, 775, 1734, 1254, 294]
+75ms ║║Executed virtual command log (2ms)
+83ms ║║Calculating (integer)14 + (integer)1 >> (integer)15
+88ms ║║Calculating (string)Bus: + (string)E2 >> (string)Bus:E2
+89ms ║║Calculating (string)Bus:E2 + (string),Expected at: >> (string)Bus:E2,Expected at:
+91ms ║║Calculating (string)Bus:E2,Expected at: + (string)15 >> (string)Bus:E2,Expected at:15
+92ms ║║Calculating (string)Bus:E2,Expected at:15 + (string):21 >> (string)Bus:E2,Expected at:15:21
+95ms ║║Bus:E2,Expected at:15:21
+97ms ║║Executed virtual command log (2ms)
+100ms ║╚Execution stage complete. (66ms)
+104ms ╚Event processed successfully (101ms)
16/08/2022, 14:54:55 +907ms
+9ms ╔Received event [27Curzon].test = 1660658095907 with a delay of 0ms, canQueue: true, calledMyself: false
+43ms ║RunTime initialize > 41 LockT > 0ms > r9T > 30ms > pistonT > 29ms (first state access 11 10 31)
+46ms ║Runtime (7292 bytes) initialized in 30ms (v0.3.114.20220418_HE)
+48ms ║╔Execution stage started
+56ms ║║Sending asynchttpGet web request to: api.tfl.gov.uk/Line/e2,e7,e8/Arrivals/490000062F
+58ms ║║Executed virtual command httpRequest (3ms)
+61ms ║║Requesting wake up at Tue, Aug 16 2022 @ 2:55:19 PM BST (in 23999ms) for 1 (st:2)
+67ms ║╚Execution stage complete. (19ms)
+97ms ║Setting up scheduled job for Tue, Aug 16 2022 @ 2:55:19 PM BST (in 24020ms)
+99ms ╚Event processed successfully (91ms)