mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
Implement removal of last stop data on shuttle removal
This commit is contained in:
@@ -534,6 +534,9 @@ export class RedisShuttleRepository extends BaseRedisRepository implements Shutt
|
|||||||
const key = this.createShuttleKey(shuttleId);
|
const key = this.createShuttleKey(shuttleId);
|
||||||
await this.redisClient.del(key);
|
await this.redisClient.del(key);
|
||||||
this.emit(ShuttleRepositoryEvent.SHUTTLE_REMOVED, shuttle);
|
this.emit(ShuttleRepositoryEvent.SHUTTLE_REMOVED, shuttle);
|
||||||
|
|
||||||
|
await this.removeShuttleLastStopIfExists(shuttleId);
|
||||||
|
|
||||||
return shuttle;
|
return shuttle;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -559,6 +562,15 @@ export class RedisShuttleRepository extends BaseRedisRepository implements Shutt
|
|||||||
return null;
|
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
|
// Clear methods
|
||||||
public async clearShuttleData(): Promise<void> {
|
public async clearShuttleData(): Promise<void> {
|
||||||
|
|||||||
@@ -267,6 +267,7 @@ export class UnoptimizedInMemoryShuttleRepository
|
|||||||
const shuttle = await this.removeEntityByIdIfExists(shuttleId, this.shuttles);
|
const shuttle = await this.removeEntityByIdIfExists(shuttleId, this.shuttles);
|
||||||
if (shuttle != null) {
|
if (shuttle != null) {
|
||||||
this.emit(ShuttleRepositoryEvent.SHUTTLE_REMOVED, shuttle);
|
this.emit(ShuttleRepositoryEvent.SHUTTLE_REMOVED, shuttle);
|
||||||
|
await this.removeShuttleLastStopIfExists(shuttleId);
|
||||||
}
|
}
|
||||||
return shuttle;
|
return shuttle;
|
||||||
}
|
}
|
||||||
@@ -282,6 +283,10 @@ export class UnoptimizedInMemoryShuttleRepository
|
|||||||
}, this.orderedStops);
|
}, this.orderedStops);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async removeShuttleLastStopIfExists(shuttleId: string) {
|
||||||
|
this.shuttleLastStopArrivals.delete(shuttleId);
|
||||||
|
}
|
||||||
|
|
||||||
public async clearShuttleData(): Promise<void> {
|
public async clearShuttleData(): Promise<void> {
|
||||||
this.shuttles = [];
|
this.shuttles = [];
|
||||||
await this.clearShuttleLastStopData();
|
await this.clearShuttleLastStopData();
|
||||||
|
|||||||
Reference in New Issue
Block a user