fix(buffer): do not update created_at for profiles since its our partition key

This commit is contained in:
Carl-Gerhard Lindesvärd
2025-03-06 11:07:09 +01:00
parent 164a18e931
commit 08b07e42fb
2 changed files with 3 additions and 10 deletions

View File

@@ -69,18 +69,11 @@ export class ProfileBuffer extends BaseBuffer {
const existingProfile = await this.fetchProfile(profile, logger);
const mergedProfile: IClickhouseProfile = existingProfile
? deepMergeObjects(existingProfile, profile)
? deepMergeObjects(existingProfile, omit(['created_at'], profile))
: profile;
// Avoid unnecessary updates:
// If the profile is less than X minutes old
// and the profiles are the same
if (profile.created_at && existingProfile?.created_at) {
const a = new Date(profile.created_at);
const b = new Date(existingProfile.created_at);
const diffTime = Math.abs(a.getTime() - b.getTime());
if (profile && existingProfile) {
if (
diffTime < 1000 * 60 * 10 &&
shallowEqual(
omit(['created_at'], existingProfile),
omit(['created_at'], mergedProfile),