Skip to content

Commit 8dd1936

Browse files
committed
fix: lint
Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
1 parent 4b50a8f commit 8dd1936

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

services/apps/script_executor_worker/src/bin/cleanup-gerrit-activities.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,10 @@ async function deletePostgresInChunks(
192192
let total = 0
193193
let batch = 0
194194
let failedBatches = 0
195+
let rows: Array<{ activityId: string }>
195196

196-
while (true) {
197-
const rows = (await postgres.select(fetchQuery, values)) as Array<{ activityId: string }>
197+
do {
198+
rows = (await postgres.select(fetchQuery, values)) as Array<{ activityId: string }>
198199
if (rows.length === 0) break
199200

200201
const ids = rows.map((r) => r.activityId)
@@ -210,12 +211,14 @@ async function deletePostgresInChunks(
210211
` Batch ${batch} delete failed (sample IDs: ${ids.slice(0, 3).join(', ')}): ${error.message}`,
211212
)
212213
failedBatches++
214+
// Stop to prevent re-fetching the same undeleted rows on the next iteration
215+
break
213216
}
214217

215218
if (batch % 10 === 0) {
216219
log.info(` … deleted ${total.toLocaleString()} rows so far (batch ${batch})`)
217220
}
218-
}
221+
} while (rows.length === batchSize)
219222

220223
return { deleted: total, failedBatches }
221224
}

0 commit comments

Comments
 (0)