FerryTempo / FTServer

A NodeJS implementation of the FerryTempo service.
https://www.ferrytempo.com/
1 stars 0 forks source link

Figure out how to make sure we update all ports with minimal data #69

Open ckulfan opened 3 months ago

ckulfan commented 3 months ago

Right now we iterate through the vessel data structure to update each of the boats and then use that data to update the corresponding ports. However, if a route has only a single boat, the ports on that route will not get fully populated. Instead they will just get the data from the one boat, leaving the other data as null (e.g. one port will have an ETA while the other will have a Departure Delay).

This will have an impact as we start to compute values like the average departure delay for a given port. If we do not process that port in our iteration, then we will not have a chance to update that value. We need a way to make sure we touch all ports regardless of whether or not there are two boats on the route.

ckulfan commented 3 months ago

Sample dataset: "pt-cou": { "boatData": { "boat1": { "ArrivalTimeMinus": 641, "ArrivingTerminalAbbrev": "POT", "ArrivingTerminalName": "Port Townsend", "AtDock": false, "BoatDepartureDelay": 59, "BoatETA": 1717539120, "DepartingTerminalName": "Coupeville ", "DepartingTerminalAbbrev": "COU", "DepartureDelayAverage": 0, "Direction": "WN", "Heading": 250, "InService": true, "LeftDock": 1717537559, "OnDuty": true, "PositionUpdated": 1717538471, "Progress": 0.5892174109056415, "ScheduledDeparture": 1717537500, "Speed": 12.7, "StopTimer": 0, "VesselName": "Kennewick", "VesselPosition": 1 } }, "routeID": "8", "portData": { "portES": { "TerminalName": "Coupeville", "TerminalAbbrev": "COU", "TerminalID": 11, "BoatAtDock": false, "NextScheduledSailing": null, "PortDepartureDelay": 59, "PortETA": null, "PortStopTimer": 0, "PortDepartureDelayAverage": 0 }, "portWN": { "TerminalName": "Port Townsend", "TerminalAbbrev": "POT", "TerminalID": 17, "BoatAtDock": false, "NextScheduledSailing": null, "PortDepartureDelay": null, "PortETA": 1717539120, "PortArrivalTimeMinus": 641 } }