Implement removal of last stop data on shuttle removal

This commit is contained in:
2025-11-14 10:26:52 -08:00
parent 1511b3c118
commit f06e778b80
2 changed files with 18 additions and 1 deletions

View File

@@ -534,6 +534,9 @@ export class RedisShuttleRepository extends BaseRedisRepository implements Shutt
const key = this.createShuttleKey(shuttleId);
await this.redisClient.del(key);
this.emit(ShuttleRepositoryEvent.SHUTTLE_REMOVED, shuttle);
await this.removeShuttleLastStopIfExists(shuttleId);
return shuttle;
}
return null;
@@ -559,6 +562,15 @@ export class RedisShuttleRepository extends BaseRedisRepository implements Shutt
return null;
}
private async removeShuttleLastStopIfExists(shuttleId: string) {
const lastStop = await this.getShuttleLastStopArrival(shuttleId);
if (lastStop) {
const key = this.createShuttleLastStopKey(shuttleId);
await this.redisClient.del(key);
return lastStop;
}
return null;
}
// Clear methods
public async clearShuttleData(): Promise<void> {
@@ -589,7 +601,7 @@ export class RedisShuttleRepository extends BaseRedisRepository implements Shutt
await this.redisClient.del(keys);
}
}
private async clearShuttleLastStopData(): Promise<void> {
const keys = await this.redisClient.keys('shuttle:laststop:*');
if (keys.length > 0) {