Automatically append last stop if missing

This commit is contained in:
Mattéo Delabre 2021-05-11 18:20:47 +02:00
parent 6b7333c46b
commit d0c2fb3a63
Signed by: matteo
GPG Key ID: AE3FBD02DC583ABB
1 changed files with 12 additions and 3 deletions

View File

@ -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 tam = require("./sources/tam");
const network = require("./network.json"); 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) { 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]);
} }
} }