diff --git a/src/__mocks__/environment.ts b/src/__mocks__/environment.ts new file mode 100644 index 0000000..6f0b850 --- /dev/null +++ b/src/__mocks__/environment.ts @@ -0,0 +1,5 @@ +export const PARKING_LOGGING_INTERVAL_MS = 10000; + +export const PARKING_HISTORICAL_AVERAGE_MINIMUM_INTERVAL = 1000; + +export const PARKING_HISTORICAL_AVERAGE_MAXIMUM_TIMESPAN = 60000 * 60 * 24; diff --git a/src/environment.ts b/src/environment.ts new file mode 100644 index 0000000..6037926 --- /dev/null +++ b/src/environment.ts @@ -0,0 +1,11 @@ +export const PARKING_LOGGING_INTERVAL_MS = process.env.PARKING_LOGGING_INTERVAL_MS + ? parseInt(process.env.PARKING_LOGGING_INTERVAL_MS) + : 600000; // Every 10 minutes + +export const PARKING_HISTORICAL_AVERAGE_MINIMUM_INTERVAL = process.env.PARKING_HISTORICAL_AVERAGE_MINIMUM_INTERVAL + ? parseInt(process.env.PARKING_HISTORICAL_AVERAGE_MINIMUM_INTERVAL) + : 60000 * 60 * 2; + +export const PARKING_HISTORICAL_AVERAGE_MAXIMUM_TIMESPAN = process.env.PARKING_HISTORICAL_AVERAGE_MAXIMUM_TIMESPAN + ? parseInt(process.env.PARKING_HISTORICAL_AVERAGE_MAXIMUM_TIMESPAN) + : 60000 * 60 * 24; diff --git a/src/repositories/parking/InMemoryParkingRepository.ts b/src/repositories/parking/InMemoryParkingRepository.ts index 6cd68aa..84cea32 100644 --- a/src/repositories/parking/InMemoryParkingRepository.ts +++ b/src/repositories/parking/InMemoryParkingRepository.ts @@ -5,7 +5,7 @@ import { } from "../../entities/ParkingRepositoryEntities"; import { HistoricalParkingAverageQueryResult, HistoricalParkingAverageQueryArguments } from "./ParkingGetterRepository"; import { CircularQueue } from "../../types/CircularQueue"; -import { PARKING_LOGGING_INTERVAL_MS } from "./ParkingRepositoryConstants"; +import { PARKING_LOGGING_INTERVAL_MS } from "../../environment"; // If every 10 minutes, two weeks of data (6x per hour * 24x per day * 7x per week * 2) export const MAX_NUM_ENTRIES = 2016; diff --git a/src/repositories/parking/ParkingRepositoryConstants.ts b/src/repositories/parking/ParkingRepositoryConstants.ts deleted file mode 100644 index 4d8b30e..0000000 --- a/src/repositories/parking/ParkingRepositoryConstants.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const PARKING_LOGGING_INTERVAL_MS = process.env.PARKING_LOGGING_INTERVAL_MS - ? parseInt(process.env.PARKING_LOGGING_INTERVAL_MS) - : 600000; // Every 10 minutes