Batch node 'weirdness' (or not!)

@nisiyama

In the interests of speeding the diagnosis of any possible bug, I have attached my flow, but please be aware, I am no Javascript programmer, so apologies for any mess!

This code is my modified take on bits and pieces discussed in Best strategy for Reading & Sorting Electricity Cost Array.

Explanation:
The problem happens when we get to the end of the available data. This data refreshes every evening after about 18:00 hours for the next 24 or so hours. If there is plenty of data present, all appears OK, but this may be due to the cheaper slots being earlier in the day. But when generating longer slots by combining say six array elements (relating to 30 minute slots with their pricing) to create a longer slot based on costs, and 'running out' of data, the problem starts to become apparent.

Let me use the 3 hour slot as the example (six array elements). The last slot available in our data is from 22:30 - 23:00, I can see 3 hour slots that are available from after 20:30. Looking at various times, I have seen the array length to be variable, sometimes correct, sometimes too many objects in the array. When the number of objects is correct, all is OK, when there are too many for the time left available, that is when the problem starts, hence the initial question.

If you need any further information, or I have confused you, please do not hesitate to ask. Apologies in advance for any basic mistakes I have made (currently check variable types!).

A big thank you for your efforts.

HTH

Octopus flows.json (38.8 KB)

Edited with updated flow to ease display of data.