1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00

fix: uintroduce call to update last_seen on client-instance

This commit is contained in:
Ivar Conradi Østhus 2021-12-09 22:32:48 +01:00
parent 573385a630
commit 08bff6359c
4 changed files with 21 additions and 2 deletions

View File

@ -77,6 +77,19 @@ export default class ClientInstanceStore implements IClientInstanceStore {
}
}
async setLastSeen({
appName,
instanceId,
environment,
clientIp,
}: INewClientInstance): Promise<void> {
await this.db(TABLE)
.update({ last_seen: new Date(), client_ip: clientIp })
.where({ app_name: appName, instance_id: instanceId, environment })
.onConflict(['app_name', 'instance_id', 'environment'])
.ignore();
}
async bulkUpsert(instances: INewClientInstance[]): Promise<void> {
const rows = instances.map(mapToDb);
await this.db(TABLE)

View File

@ -94,10 +94,11 @@ export default class ClientInstanceService {
clientIp: string,
): Promise<void> {
const value = await clientMetricsSchema.validateAsync(data);
await this.clientInstanceStore.insert({
await this.clientInstanceStore.setLastSeen({
appName: value.appName,
instanceId: value.instanceId,
clientIp,
environment: value.environment,
clientIp: clientIp,
});
}

View File

@ -18,6 +18,7 @@ export interface IClientInstanceStore
Pick<INewClientInstance, 'appName' | 'instanceId'>
> {
bulkUpsert(instances: INewClientInstance[]): Promise<void>;
setLastSeen(INewClientInstance): Promise<void>;
insert(details: INewClientInstance): Promise<void>;
getByAppName(appName: string): Promise<IClientInstance[]>;
getDistinctApplications(): Promise<string[]>;

View File

@ -27,6 +27,10 @@ export default class FakeClientInstanceStore implements IClientInstanceStore {
);
}
setLastSeen(): Promise<void> {
return;
}
async deleteAll(): Promise<void> {
this.instances = [];
}