make all loader methods public for improved testing

This commit is contained in:
2025-01-22 13:25:16 -08:00
parent 82a69ca464
commit 86777a1681

View File

@@ -6,11 +6,11 @@ const baseUrl = "https://passiogo.com/mapGetData.php";
export class ApiBasedRepositoryLoader { export class ApiBasedRepositoryLoader {
constructor( constructor(
protected repository: GetterSetterRepository, public repository: GetterSetterRepository,
) { ) {
} }
protected async fetchAndUpdateSystemData() { public async fetchAndUpdateSystemData() {
const params = { const params = {
getSystems: "2", getSystems: "2",
}; };
@@ -32,7 +32,7 @@ export class ApiBasedRepositoryLoader {
} }
} }
protected async fetchAndUpdateRouteDataForExistingSystems() { public async fetchAndUpdateRouteDataForExistingSystems() {
const systems = await this.repository.getSystems(); const systems = await this.repository.getSystems();
await Promise.all(systems.map(async (system) => { await Promise.all(systems.map(async (system) => {
const params = { const params = {
@@ -69,7 +69,7 @@ export class ApiBasedRepositoryLoader {
})); }));
} }
protected async fetchAndUpdateStopAndPolylineDataForRoutesInExistingSystems() { public async fetchAndUpdateStopAndPolylineDataForRoutesInExistingSystems() {
// 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 systems = await this.repository.getSystems(); const systems = await this.repository.getSystems();
@@ -98,7 +98,7 @@ export class ApiBasedRepositoryLoader {
})); }));
} }
protected async fetchAndUpdateShuttleDataForExistingSystems() { public async fetchAndUpdateShuttleDataForExistingSystems() {
const systems = await this.repository.getSystems(); const systems = await this.repository.getSystems();
await Promise.all(systems.map(async (system: ISystem) => { await Promise.all(systems.map(async (system: ISystem) => {
const params = { const params = {
@@ -143,7 +143,7 @@ export class ApiBasedRepositoryLoader {
})); }));
} }
protected async fetchAndUpdateEtaDataForExistingOrderedStops() { public async fetchAndUpdateEtaDataForExistingOrderedStops() {
// TODO implement once I figure out how to associate ETA data with shuttles // TODO implement once I figure out how to associate ETA data with shuttles
const systems = await this.repository.getSystems() const systems = await this.repository.getSystems()
@@ -181,7 +181,7 @@ export class ApiBasedRepositoryLoader {
})) }))
} }
protected async updateStopDataForSystemAndApiResponse(system: ISystem, json: any) { public async updateStopDataForSystemAndApiResponse(system: ISystem, json: any) {
if (json.stops) { if (json.stops) {
const jsonStops = Object.values(json.stops); const jsonStops = Object.values(json.stops);
@@ -201,7 +201,7 @@ export class ApiBasedRepositoryLoader {
} }
} }
protected async updateOrderedStopDataForExistingStops(json: any) { public async updateOrderedStopDataForExistingStops(json: any) {
if (json.routes) { if (json.routes) {
await Promise.all(Object.keys(json.routes).map(async (routeId) => { await Promise.all(Object.keys(json.routes).map(async (routeId) => {
const jsonOrderedStopData: any[][] = json.routes[routeId].slice(2); const jsonOrderedStopData: any[][] = json.routes[routeId].slice(2);
@@ -246,7 +246,7 @@ export class ApiBasedRepositoryLoader {
} }
} }
protected async updatePolylineDataForExistingRoutesAndApiResponse(json: any) { public async updatePolylineDataForExistingRoutesAndApiResponse(json: any) {
if (json.routePoints) { if (json.routePoints) {
await Promise.all(Object.keys(json.routePoints).map(async (routeId) => { await Promise.all(Object.keys(json.routePoints).map(async (routeId) => {
const routePoints = json.routePoints[routeId][0]; const routePoints = json.routePoints[routeId][0];