Skip to content

Commit 37ae27a

Browse files
committed
update: correctly show the number of sucessfully processed items
1 parent 3476ec4 commit 37ae27a

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

core/src/main/java/com/fpf/smartscansdk/core/processors/BatchProcessor.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ abstract class BatchProcessor<Input, Output>(
2424
open suspend fun run(items: List<Input>): Metrics = withContext(Dispatchers.IO) {
2525
val processedCount = AtomicInteger(0)
2626
val startTime = System.currentTimeMillis()
27+
var totalSuccess = 0
2728

2829
try {
2930
if (items.isEmpty()) {
@@ -58,11 +59,12 @@ abstract class BatchProcessor<Input, Output>(
5859
}
5960

6061
val outputBatch = deferredResults.mapNotNull { it.await() }
62+
totalSuccess += outputBatch.size
6163
onBatchComplete(application, outputBatch)
6264
}
6365

6466
val endTime = System.currentTimeMillis()
65-
val metrics = Metrics.Success(processedCount.get(), timeElapsed = endTime - startTime)
67+
val metrics = Metrics.Success(totalSuccess, timeElapsed = endTime - startTime)
6668

6769
listener?.onComplete(application, metrics)
6870
metrics
@@ -72,7 +74,7 @@ abstract class BatchProcessor<Input, Output>(
7274
}
7375
catch (e: Exception) {
7476
val metrics = Metrics.Failure(
75-
processedBeforeFailure = processedCount.get(),
77+
processedBeforeFailure = totalSuccess,
7678
timeElapsed = System.currentTimeMillis() - startTime,
7779
error = e
7880
)

0 commit comments

Comments
 (0)