mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +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> { | ||||
|         const rows = instances.map(mapToDb); | ||||
|         await this.db(TABLE) | ||||
|  | ||||
| @ -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, | ||||
|         }); | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -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[]>; | ||||
|  | ||||
| @ -27,6 +27,10 @@ export default class FakeClientInstanceStore implements IClientInstanceStore { | ||||
|         ); | ||||
|     } | ||||
| 
 | ||||
|     setLastSeen(): Promise<void> { | ||||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     async deleteAll(): Promise<void> { | ||||
|         this.instances = []; | ||||
|     } | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user