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:
parent
573385a630
commit
08bff6359c
@ -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> {
|
async bulkUpsert(instances: INewClientInstance[]): Promise<void> {
|
||||||
const rows = instances.map(mapToDb);
|
const rows = instances.map(mapToDb);
|
||||||
await this.db(TABLE)
|
await this.db(TABLE)
|
||||||
|
@ -94,10 +94,11 @@ export default class ClientInstanceService {
|
|||||||
clientIp: string,
|
clientIp: string,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const value = await clientMetricsSchema.validateAsync(data);
|
const value = await clientMetricsSchema.validateAsync(data);
|
||||||
await this.clientInstanceStore.insert({
|
await this.clientInstanceStore.setLastSeen({
|
||||||
appName: value.appName,
|
appName: value.appName,
|
||||||
instanceId: value.instanceId,
|
instanceId: value.instanceId,
|
||||||
clientIp,
|
environment: value.environment,
|
||||||
|
clientIp: clientIp,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ export interface IClientInstanceStore
|
|||||||
Pick<INewClientInstance, 'appName' | 'instanceId'>
|
Pick<INewClientInstance, 'appName' | 'instanceId'>
|
||||||
> {
|
> {
|
||||||
bulkUpsert(instances: INewClientInstance[]): Promise<void>;
|
bulkUpsert(instances: INewClientInstance[]): Promise<void>;
|
||||||
|
setLastSeen(INewClientInstance): Promise<void>;
|
||||||
insert(details: INewClientInstance): Promise<void>;
|
insert(details: INewClientInstance): Promise<void>;
|
||||||
getByAppName(appName: string): Promise<IClientInstance[]>;
|
getByAppName(appName: string): Promise<IClientInstance[]>;
|
||||||
getDistinctApplications(): Promise<string[]>;
|
getDistinctApplications(): Promise<string[]>;
|
||||||
|
@ -27,6 +27,10 @@ export default class FakeClientInstanceStore implements IClientInstanceStore {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setLastSeen(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
async deleteAll(): Promise<void> {
|
async deleteAll(): Promise<void> {
|
||||||
this.instances = [];
|
this.instances = [];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user