1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-06-27 01:19:00 +02:00

feat: remove instances older than 1 day not 2 days (#9944)

This commit is contained in:
Mateusz Kwasniewski 2025-05-09 13:58:52 +02:00 committed by GitHub
parent 7a012ce910
commit e414c4446d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 7 additions and 9 deletions

View File

@ -61,9 +61,9 @@ export default class ClientInstanceStore implements IClientInstanceStore {
});
}
async removeInstancesOlderThanTwoDays(): Promise<void> {
async removeOldInstances(): Promise<void> {
const rows = await this.db(TABLE)
.whereRaw("last_seen < now() - interval '2 days'")
.whereRaw("last_seen < now() - interval '1 days'")
.del();
if (rows > 0) {

View File

@ -316,8 +316,8 @@ export default class ClientInstanceService {
await this.clientApplicationsStore.upsert(input);
}
async removeInstancesOlderThanTwoDays(): Promise<void> {
return this.clientInstanceStore.removeInstancesOlderThanTwoDays();
async removeOldInstances(): Promise<void> {
return this.clientInstanceStore.removeOldInstances();
}
async removeInactiveApplications(): Promise<number> {

View File

@ -72,9 +72,7 @@ export const scheduleServices = async (
);
schedulerService.schedule(
clientInstanceService.removeInstancesOlderThanTwoDays.bind(
clientInstanceService,
),
clientInstanceService.removeOldInstances.bind(clientInstanceService),
hoursToMilliseconds(24),
'removeInstancesOlderThanTwoDays',
);

View File

@ -35,5 +35,5 @@ export interface IClientInstanceStore
getDistinctApplications(): Promise<string[]>;
getDistinctApplicationsCount(daysBefore?: number): Promise<number>;
deleteForApplication(appName: string): Promise<void>;
removeInstancesOlderThanTwoDays(): Promise<void>;
removeOldInstances(): Promise<void>;
}

View File

@ -117,7 +117,7 @@ export default class FakeClientInstanceStore implements IClientInstanceStore {
this.instances.push({ createdAt: new Date(), ...details });
}
removeInstancesOlderThanTwoDays(): Promise<void> {
removeOldInstances(): Promise<void> {
return Promise.resolve(undefined);
}
}