fix pruning and construction ID issues with repository loader

This commit is contained in:
2025-04-07 13:47:36 -07:00
parent 6767cc88a3
commit fe6db035f1

View File

@@ -36,7 +36,7 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader
public async fetchAndUpdateRouteDataForSystem() {
const systemId = this.passioSystemId;
const routeIdsToPrune = await this.constructExistingEntityIdSet(async () => {
return await this.repository.getRoutesBySystemId(systemId);
return await this.repository.getRoutesBySystemId(this.systemIdForConstructedData);
});
const params = {
@@ -84,12 +84,12 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader
}
public async fetchAndUpdateStopAndPolylineDataForRoutesInSystem() {
const systemId = this.passioSystemId;
const passioSystemId = this.passioSystemId;
// Fetch from the API
// Pass JSON output into two different methods to update repository
const stopIdsToPrune = await this.constructExistingEntityIdSet(async () => {
return await this.repository.getStopsBySystemId(systemId);
return await this.repository.getStopsBySystemId(this.systemIdForConstructedData);
});
const params = {
@@ -97,7 +97,7 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader
};
const formDataJsonObject = {
"s0": systemId,
"s0": passioSystemId,
"sA": 1
};
const formData = new FormData();
@@ -112,7 +112,7 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader
});
const json = await response.json();
await this.updateStopDataForSystemAndApiResponse(systemId, json, stopIdsToPrune);
await this.updateStopDataForSystemAndApiResponse(json, stopIdsToPrune);
await this.updateOrderedStopDataForExistingStops(json);
await this.updatePolylineDataForExistingRoutesAndApiResponse(json);
@@ -127,7 +127,7 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader
public async fetchAndUpdateShuttleDataForSystem() {
const systemId = this.passioSystemId;
const shuttleIdsToPrune = await this.constructExistingEntityIdSet(async () => {
return await this.repository.getShuttlesBySystemId(systemId);
return await this.repository.getShuttlesBySystemId(this.systemIdForConstructedData);
});
const params = {
@@ -228,7 +228,6 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader
}
protected async updateStopDataForSystemAndApiResponse(
systemId: string,
json: any,
setOfIdsToPrune: Set<string> = new Set(),
) {
@@ -239,7 +238,7 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader
const constructedStop: IStop = {
name: stop.name,
id: stop.id,
systemId,
systemId: this.systemIdForConstructedData,
coordinates: {
latitude: parseFloat(stop.latitude),
longitude: parseFloat(stop.longitude),