rename existing repository to shuttle repository

This commit is contained in:
2025-03-27 09:32:29 -07:00
parent 3a85f3da8b
commit fab99db755
15 changed files with 46 additions and 47 deletions

View File

@@ -1,4 +1,4 @@
import { GetterRepository } from "../../repositories/GetterRepository";
import { ShuttleGetterRepository } from "../../repositories/ShuttleGetterRepository";
import { TupleKey } from "../../types/TupleKey";
import { IEta } from "../../entities/entities";
import { AppleNotificationSender, NotificationAlertArguments } from "../senders/AppleNotificationSender";
@@ -24,7 +24,7 @@ type DeviceIdSecondsThresholdAssociation = { [key: string]: number };
export class ETANotificationScheduler {
public static readonly defaultSecondsThresholdForNotificationToFire = 180;
constructor(private repository: GetterRepository,
constructor(private shuttleRepository: ShuttleGetterRepository,
private appleNotificationSender = new AppleNotificationSender()
) {
this.etaSubscriberCallback = this.etaSubscriberCallback.bind(this);
@@ -50,9 +50,9 @@ export class ETANotificationScheduler {
private async sendEtaNotificationImmediately(notificationData: NotificationSchedulingArguments): Promise<boolean> {
const { deviceId, shuttleId, stopId } = notificationData;
const shuttle = await this.repository.getShuttleById(shuttleId);
const stop = await this.repository.getStopById(stopId);
const eta = await this.repository.getEtaForShuttleAndStopId(shuttleId, stopId);
const shuttle = await this.shuttleRepository.getShuttleById(shuttleId);
const stop = await this.shuttleRepository.getStopById(stopId);
const eta = await this.shuttleRepository.getEtaForShuttleAndStopId(shuttleId, stopId);
if (!shuttle) {
console.warn(`Notification ${notificationData} fell through; no associated shuttle`);
return false;
@@ -127,8 +127,8 @@ export class ETANotificationScheduler {
this.deviceIdsToDeliverTo[tuple.toString()][deviceId] = secondsThreshold;
this.repository.unsubscribeFromEtaUpdates(this.etaSubscriberCallback);
this.repository.subscribeToEtaUpdates(this.etaSubscriberCallback);
this.shuttleRepository.unsubscribeFromEtaUpdates(this.etaSubscriberCallback);
this.shuttleRepository.subscribeToEtaUpdates(this.etaSubscriberCallback);
}
/**