Filter out out-of-service shuttles

This commit is contained in:
2025-09-26 16:01:32 -07:00
parent 5ed15ee534
commit 155ab2b4d2

View File

@@ -159,7 +159,7 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader
public async updateShuttleDataForSystemBasedOnProximityToRoutes() {
try {
const json = await this.fetchShuttleDataJson();
let shuttles = this.constructShuttlesFromJson(json);
let shuttles = this.constructInServiceShuttlesFromJson(json);
if (shuttles !== null) {
shuttles = await this.filterShuttlesByDistanceFromCorrespondingRoute(shuttles);
await this.updateShuttleDataInRepository(shuttles);
@@ -210,11 +210,12 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader
return await response.json();
}
private constructShuttlesFromJson(json: any): IShuttle[] | null {
private constructInServiceShuttlesFromJson(json: any): IShuttle[] | null {
if (json.buses && json.buses["-1"] === undefined) {
const jsonBuses = Object.values(json.buses).map((busesArr: any) => {
return busesArr[0];
});
jsonBuses.filter((bus) => bus.outOfService != 0)
return jsonBuses.map((jsonBus: any) => {
const constructedShuttle: IShuttle = {