mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 16:00:32 +00:00
differentiate between passio system ID and internal ID in loader class
This commit is contained in:
@@ -18,7 +18,8 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader
|
||||
baseUrl = "https://passiogo.com/mapGetData.php";
|
||||
|
||||
constructor(
|
||||
public systemId: string,
|
||||
public passioSystemId: string,
|
||||
public systemIdForConstructedData: string,
|
||||
public repository: ShuttleGetterSetterRepository,
|
||||
) {
|
||||
}
|
||||
@@ -33,7 +34,7 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader
|
||||
}
|
||||
|
||||
public async fetchAndUpdateRouteDataForSystem() {
|
||||
const systemId = this.systemId;
|
||||
const systemId = this.passioSystemId;
|
||||
const routeIdsToPrune = await this.constructExistingEntityIdSet(async () => {
|
||||
return await this.repository.getRoutesBySystemId(systemId);
|
||||
});
|
||||
@@ -65,7 +66,7 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader
|
||||
color: jsonRoute.color,
|
||||
id: jsonRoute.myid,
|
||||
polylineCoordinates: [],
|
||||
systemId: systemId,
|
||||
systemId: this.systemIdForConstructedData,
|
||||
};
|
||||
|
||||
await this.repository.addOrUpdateRoute(constructedRoute);
|
||||
@@ -83,7 +84,7 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader
|
||||
}
|
||||
|
||||
public async fetchAndUpdateStopAndPolylineDataForRoutesInSystem() {
|
||||
const systemId = this.systemId;
|
||||
const systemId = this.passioSystemId;
|
||||
|
||||
// Fetch from the API
|
||||
// Pass JSON output into two different methods to update repository
|
||||
@@ -124,7 +125,7 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader
|
||||
}
|
||||
|
||||
public async fetchAndUpdateShuttleDataForSystem() {
|
||||
const systemId = this.systemId;
|
||||
const systemId = this.passioSystemId;
|
||||
const shuttleIdsToPrune = await this.constructExistingEntityIdSet(async () => {
|
||||
return await this.repository.getShuttlesBySystemId(systemId);
|
||||
});
|
||||
@@ -163,7 +164,7 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader
|
||||
longitude: parseFloat(jsonBus.longitude),
|
||||
},
|
||||
routeId: jsonBus.routeId,
|
||||
systemId: systemId,
|
||||
systemId: this.systemIdForConstructedData,
|
||||
id: `${jsonBus.busId}`,
|
||||
orientationInDegrees: parseFloat(jsonBus.calculatedCourse)
|
||||
}
|
||||
@@ -183,7 +184,7 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader
|
||||
}
|
||||
|
||||
public async fetchAndUpdateEtaDataForExistingStopsForSystem() {
|
||||
const stops = await this.repository.getStopsBySystemId(this.systemId);
|
||||
const stops = await this.repository.getStopsBySystemId(this.passioSystemId);
|
||||
await Promise.all(stops.map(async (stop) => {
|
||||
let stopId = stop.id;
|
||||
await this.fetchAndUpdateEtaDataForStopId(stopId);
|
||||
@@ -215,7 +216,7 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader
|
||||
shuttleId: `${shuttleId}`,
|
||||
stopId: stopId,
|
||||
millisecondsSinceEpoch: Date.now(),
|
||||
systemId: this.systemId,
|
||||
systemId: this.systemIdForConstructedData,
|
||||
};
|
||||
|
||||
this.repository.addOrUpdateEta(eta);
|
||||
@@ -273,7 +274,7 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader
|
||||
routeId,
|
||||
stopId,
|
||||
position: index + 1,
|
||||
systemId: this.systemId,
|
||||
systemId: this.systemIdForConstructedData,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -282,7 +283,7 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader
|
||||
routeId,
|
||||
stopId: jsonOrderedStopData[index - 1][1],
|
||||
position: index,
|
||||
systemId: this.systemId,
|
||||
systemId: this.systemIdForConstructedData,
|
||||
};
|
||||
}
|
||||
if (index < jsonOrderedStopData.length - 1) {
|
||||
@@ -290,7 +291,7 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader
|
||||
routeId,
|
||||
stopId: jsonOrderedStopData[index + 1][1],
|
||||
position: index + 2,
|
||||
systemId: this.systemId,
|
||||
systemId: this.systemIdForConstructedData,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -22,10 +22,11 @@ export class TimedApiBasedShuttleRepositoryLoader extends ApiBasedShuttleReposit
|
||||
readonly timeout = 10000;
|
||||
|
||||
constructor(
|
||||
public systemId: string,
|
||||
public passioSystemId: string,
|
||||
public systemIdForConstructedData: string,
|
||||
repository: ShuttleGetterSetterRepository,
|
||||
) {
|
||||
super(systemId, repository);
|
||||
super(passioSystemId, systemIdForConstructedData, repository);
|
||||
this.startFetchDataAndUpdate = this.startFetchDataAndUpdate.bind(this);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user