add functionality to normalize the spots available if over capacity

This commit is contained in:
2025-04-16 17:18:48 -07:00
parent 658222b91a
commit 02e440773a
2 changed files with 18 additions and 4 deletions

View File

@@ -48,7 +48,7 @@ export class ChapmanApiBasedParkingRepositoryLoader implements ParkingRepository
}
}
private constructIParkingStructureFromJson(jsonStructure: any) {
public constructIParkingStructureFromJson(jsonStructure: any) {
const structureToReturn: IParkingStructure = {
capacity: jsonStructure.Capacity,
coordinates: {
@@ -57,7 +57,7 @@ export class ChapmanApiBasedParkingRepositoryLoader implements ParkingRepository
},
id: ChapmanApiBasedParkingRepositoryLoader.generateId(jsonStructure.Address),
name: jsonStructure.Name,
spotsAvailable: jsonStructure.CurrentCount,
spotsAvailable: jsonStructure.CurrentCount > jsonStructure.Capacity ? jsonStructure.Capacity : jsonStructure.CurrentCount,
address: jsonStructure.Address
}