Skip to content

Commit 2f565c3

Browse files
committed
When merging batches, keep the last occurrence items with the same version
1 parent 3400d80 commit 2f565c3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

apps/webapp/app/services/runsReplicationService.server.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,10 @@ export class RunsReplicationService {
145145
const key = `${item.event}_${item.run.id}`;
146146
const existingItem = merged.get(key);
147147

148-
// keep the run with the higher version (latest)
149-
if (!existingItem || item._version > existingItem._version) {
148+
// Keep the run with the higher version (latest)
149+
// and take the last occurrence for that version.
150+
// Items originating from the same DB transaction have the same version.
151+
if (!existingItem || item._version >= existingItem._version) {
150152
merged.set(key, item);
151153
}
152154
}

0 commit comments

Comments
 (0)