mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 16:00:32 +00:00
Add getHistoricalAveragesOfParkingStructureCounts stub and update constructor with dependency injection support
This commit is contained in:
@@ -1,36 +1,44 @@
|
||||
import { ParkingGetterSetterRepository } from "./ParkingGetterSetterRepository";
|
||||
import { IParkingStructure } from "../entities/ParkingRepositoryEntities";
|
||||
import {
|
||||
IParkingStructure,
|
||||
IParkingStructureTimestampRecord
|
||||
} from "../entities/ParkingRepositoryEntities";
|
||||
import { HistoricalParkingAverageQueryResult } from "./ParkingGetterRepository";
|
||||
|
||||
type ParkingStructureID = string;
|
||||
|
||||
export class InMemoryParkingRepository implements ParkingGetterSetterRepository {
|
||||
private structures: Map<string, IParkingStructure>;
|
||||
|
||||
constructor() {
|
||||
this.structures = new Map<string, IParkingStructure>();
|
||||
constructor(
|
||||
private structures: Map<ParkingStructureID, IParkingStructure> = new Map(),
|
||||
private historicalData: Map<ParkingStructureID, IParkingStructureTimestampRecord[]> = new Map(),
|
||||
) {
|
||||
}
|
||||
|
||||
async addOrUpdateParkingStructure(structure: IParkingStructure): Promise<void> {
|
||||
addOrUpdateParkingStructure = async (structure: IParkingStructure): Promise<void> => {
|
||||
this.structures.set(structure.id, { ...structure });
|
||||
}
|
||||
};
|
||||
|
||||
async clearParkingStructureData(): Promise<void> {
|
||||
clearParkingStructureData = async (): Promise<void> => {
|
||||
this.structures.clear();
|
||||
}
|
||||
};
|
||||
|
||||
async getParkingStructureById(id: string): Promise<IParkingStructure | null> {
|
||||
getParkingStructureById = async (id: string): Promise<IParkingStructure | null> => {
|
||||
const structure = this.structures.get(id);
|
||||
return structure ? { ...structure } : null;
|
||||
}
|
||||
};
|
||||
|
||||
async getParkingStructures(): Promise<IParkingStructure[]> {
|
||||
return Array.from(this.structures.values()).map(structure => ({ ...structure }));
|
||||
}
|
||||
getParkingStructures = async (): Promise<IParkingStructure[]> => Array.from(this.structures.values()).map(structure => ({...structure}));
|
||||
|
||||
async removeParkingStructureIfExists(id: string): Promise<IParkingStructure | null> {
|
||||
removeParkingStructureIfExists = async (id: string): Promise<IParkingStructure | null> => {
|
||||
const structure = this.structures.get(id);
|
||||
if (structure) {
|
||||
this.structures.delete(id);
|
||||
return { ...structure };
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
getHistoricalAveragesOfParkingStructureCounts = async (id: string): Promise<HistoricalParkingAverageQueryResult[]> => {
|
||||
return [];
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user