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