Automatically append last stop if missing
This commit is contained in:
parent
6b7333c46b
commit
d0c2fb3a63
|
@ -1,5 +1,10 @@
|
|||
const path = require("path");
|
||||
const fs = require("fs").promises;
|
||||
/**
|
||||
* @fileoverview
|
||||
*
|
||||
* Fetch and aggregate information about vehicles in transit on the TaM network
|
||||
* from the official endpoints.
|
||||
*/
|
||||
|
||||
const tam = require("./sources/tam");
|
||||
const network = require("./network.json");
|
||||
|
||||
|
@ -112,8 +117,12 @@ const fetch = async (kind = 'realtime') => {
|
|||
)
|
||||
);
|
||||
|
||||
const lastPassing = course.passings[course.passings.length - 1];
|
||||
|
||||
if (course.finalStopId === undefined) {
|
||||
course.finalStopId = course.passings[course.passings.length - 1][0];
|
||||
course.finalStopId = lastPassing[0];
|
||||
} else if (course.finalStopId !== lastPassing[0]) {
|
||||
course.passings.push([course.finalStopId, lastPassing[1] + 30000]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue