mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +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 { 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 {
|
export class InMemoryParkingRepository implements ParkingGetterSetterRepository {
|
||||||
private structures: Map<string, IParkingStructure>;
|
constructor(
|
||||||
|
private structures: Map<ParkingStructureID, IParkingStructure> = new Map(),
|
||||||
constructor() {
|
private historicalData: Map<ParkingStructureID, IParkingStructureTimestampRecord[]> = new Map(),
|
||||||
this.structures = new Map<string, IParkingStructure>();
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async addOrUpdateParkingStructure(structure: IParkingStructure): Promise<void> {
|
addOrUpdateParkingStructure = async (structure: IParkingStructure): Promise<void> => {
|
||||||
this.structures.set(structure.id, { ...structure });
|
this.structures.set(structure.id, { ...structure });
|
||||||
}
|
};
|
||||||
|
|
||||||
async clearParkingStructureData(): Promise<void> {
|
clearParkingStructureData = async (): Promise<void> => {
|
||||||
this.structures.clear();
|
this.structures.clear();
|
||||||
}
|
};
|
||||||
|
|
||||||
async getParkingStructureById(id: string): Promise<IParkingStructure | null> {
|
getParkingStructureById = async (id: string): Promise<IParkingStructure | null> => {
|
||||||
const structure = this.structures.get(id);
|
const structure = this.structures.get(id);
|
||||||
return structure ? { ...structure } : null;
|
return structure ? { ...structure } : null;
|
||||||
}
|
};
|
||||||
|
|
||||||
async getParkingStructures(): Promise<IParkingStructure[]> {
|
getParkingStructures = async (): Promise<IParkingStructure[]> => Array.from(this.structures.values()).map(structure => ({...structure}));
|
||||||
return 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);
|
const structure = this.structures.get(id);
|
||||||
if (structure) {
|
if (structure) {
|
||||||
this.structures.delete(id);
|
this.structures.delete(id);
|
||||||
return { ...structure };
|
return { ...structure };
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
getHistoricalAveragesOfParkingStructureCounts = async (id: string): Promise<HistoricalParkingAverageQueryResult[]> => {
|
||||||
|
return [];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user