From 86777a16811fb4f246f7c7e44b7ffb5248a97ccb Mon Sep 17 00:00:00 2001 From: Brendan Chen Date: Wed, 22 Jan 2025 13:25:16 -0800 Subject: [PATCH] make all loader methods public for improved testing --- src/loaders/ApiBasedRepositoryLoader.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/loaders/ApiBasedRepositoryLoader.ts b/src/loaders/ApiBasedRepositoryLoader.ts index 964dac0..b9b9cd2 100644 --- a/src/loaders/ApiBasedRepositoryLoader.ts +++ b/src/loaders/ApiBasedRepositoryLoader.ts @@ -6,11 +6,11 @@ const baseUrl = "https://passiogo.com/mapGetData.php"; export class ApiBasedRepositoryLoader { constructor( - protected repository: GetterSetterRepository, + public repository: GetterSetterRepository, ) { } - protected async fetchAndUpdateSystemData() { + public async fetchAndUpdateSystemData() { const params = { getSystems: "2", }; @@ -32,7 +32,7 @@ export class ApiBasedRepositoryLoader { } } - protected async fetchAndUpdateRouteDataForExistingSystems() { + public async fetchAndUpdateRouteDataForExistingSystems() { const systems = await this.repository.getSystems(); await Promise.all(systems.map(async (system) => { const params = { @@ -69,7 +69,7 @@ export class ApiBasedRepositoryLoader { })); } - protected async fetchAndUpdateStopAndPolylineDataForRoutesInExistingSystems() { + public async fetchAndUpdateStopAndPolylineDataForRoutesInExistingSystems() { // Fetch from the API // Pass JSON output into two different methods to update repository 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(); await Promise.all(systems.map(async (system: ISystem) => { 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 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) { 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) { await Promise.all(Object.keys(json.routes).map(async (routeId) => { 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) { await Promise.all(Object.keys(json.routePoints).map(async (routeId) => { const routePoints = json.routePoints[routeId][0];