mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-16 23:40:32 +00:00
Filter out out-of-service shuttles
This commit is contained in:
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user