From 77365391c29cf1105ef159b8baaf3df4e82c4e52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Gerhard=20Lindesva=CC=88rd?= Date: Tue, 4 Feb 2025 13:39:28 +0100 Subject: [PATCH] improve(buffer): understand better if checksum is broken or not --- packages/db/src/buffers/profile-buffer-psql.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/db/src/buffers/profile-buffer-psql.ts b/packages/db/src/buffers/profile-buffer-psql.ts index 1883015d..0ad130c0 100644 --- a/packages/db/src/buffers/profile-buffer-psql.ts +++ b/packages/db/src/buffers/profile-buffer-psql.ts @@ -113,6 +113,10 @@ export class ProfileBuffer extends BaseBuffer { } else if (existingProfile.payload) { this.logger.debug('Profile in buffer is different, merging', { profileId: profile.id, + existingProfile: existingProfile.payload, + existingProfileChecksum: existingProfile.checksum, + incomingProfile: profile, + incomingProfileChecksum: checksum, }); mergedProfile = mergeDeepRight(existingProfile.payload, profile); } @@ -154,6 +158,12 @@ export class ProfileBuffer extends BaseBuffer { FROM ${TABLE_NAMES.profiles} WHERE project_id = '${profile.project_id}' AND id = '${profile.id}' + ${ + // If profile is not external, we know its not older than 2 day + profile.is_external === false + ? 'AND created_at > now() - INTERVAL 2 DAY' + : '' + } ORDER BY created_at DESC LIMIT 1`, );