Skip to content

Commit 139604e

Browse files
authored
fix: deduplicate results by result id (#3429)
Signed-off-by: Uroš Marolt <uros@marolt.me>
1 parent 6b5744a commit 139604e

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

services/apps/data_sink_worker/src/service/dataSink.service.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -253,13 +253,18 @@ export default class DataSinkService extends LoggerBase {
253253
const batch: { resultId: string; data: IResultData | undefined; created: boolean }[] = []
254254
for (const result of resultsToProcess) {
255255
const filtered = resultsToProcess.filter((r) => r.resultId === result.resultId)
256-
if (filtered.length > 1) {
257-
this.log.warn(
258-
{ resultId: result.resultId },
259-
'Found multiple results for the same result id!',
260-
)
256+
257+
// check if we already have this result in the batch
258+
if (!batch.some((b) => b.resultId === filtered[0].resultId)) {
259+
if (filtered.length > 1) {
260+
this.log.warn(
261+
{ resultId: result.resultId },
262+
'Found multiple results for the same result id!',
263+
)
264+
}
265+
266+
batch.push(filtered[0])
261267
}
262-
batch.push(filtered[0])
263268
}
264269

265270
this.log.trace(`[RESULTS] Processing ${batch.length} results!`)

0 commit comments

Comments
 (0)