mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +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() {
|
public async updateShuttleDataForSystemBasedOnProximityToRoutes() {
|
||||||
try {
|
try {
|
||||||
const json = await this.fetchShuttleDataJson();
|
const json = await this.fetchShuttleDataJson();
|
||||||
let shuttles = this.constructShuttlesFromJson(json);
|
let shuttles = this.constructInServiceShuttlesFromJson(json);
|
||||||
if (shuttles !== null) {
|
if (shuttles !== null) {
|
||||||
shuttles = await this.filterShuttlesByDistanceFromCorrespondingRoute(shuttles);
|
shuttles = await this.filterShuttlesByDistanceFromCorrespondingRoute(shuttles);
|
||||||
await this.updateShuttleDataInRepository(shuttles);
|
await this.updateShuttleDataInRepository(shuttles);
|
||||||
@@ -210,11 +210,12 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader
|
|||||||
return await response.json();
|
return await response.json();
|
||||||
}
|
}
|
||||||
|
|
||||||
private constructShuttlesFromJson(json: any): IShuttle[] | null {
|
private constructInServiceShuttlesFromJson(json: any): IShuttle[] | null {
|
||||||
if (json.buses && json.buses["-1"] === undefined) {
|
if (json.buses && json.buses["-1"] === undefined) {
|
||||||
const jsonBuses = Object.values(json.buses).map((busesArr: any) => {
|
const jsonBuses = Object.values(json.buses).map((busesArr: any) => {
|
||||||
return busesArr[0];
|
return busesArr[0];
|
||||||
});
|
});
|
||||||
|
jsonBuses.filter((bus) => bus.outOfService != 0)
|
||||||
|
|
||||||
return jsonBuses.map((jsonBus: any) => {
|
return jsonBuses.map((jsonBus: any) => {
|
||||||
const constructedShuttle: IShuttle = {
|
const constructedShuttle: IShuttle = {
|
||||||
|
|||||||
Reference in New Issue
Block a user