Skip to content

Commit

Permalink
[sdk] Tweak UnindexReport interface and fix error file count
Browse files Browse the repository at this point in the history
- provide clearer methods to collect the counts
  of files which were not unindexed successfully
  • Loading branch information
Enet4 committed Jun 17, 2024
1 parent 216b11f commit 471566c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws S
for (Task<UnindexReport> task: tasks) {
try {
UnindexReport report = task.get();
indexed = uris.size() - report.errorCount();
failed = report.getUnindexFailures().size();
indexed = uris.size() - report.notUnindexedFileCount();
failed = report.failedFileCount();
notfound = report.getNotFound().size();
} catch (Exception ex) {
logger.error("Task to unindex items in {} failed", providers.get(i), ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,30 @@ public Collection<URI> getNotFound() {
return Collections.unmodifiableCollection(this.notFound);
}

/** Returns the total count of errors reported during unindexing
* due to either not having been found or other failures.
/** Returns the total count of failures reported during unindexing.
*
* Note that this does not necessarily correspond to
* the number of files affected,
* and does not include files which were not found.
*/
public long failureCount() {
return this.failures.size();
}

/** Returns the total count of files which were not unindexed,
* whether because they were not found
* or could not be unindexed for other reasons.
*/
public long notUnindexedFileCount() {
return this.notFound.size() + failedFileCount();
}

/** Returns the total count of files which failed to unindexed
* for reasons other than the files not being found.
*/
public long errorCount() {
return this.failures.size() + this.notFound.size();
public long failedFileCount() {
return this.failures.stream()
.mapToLong(f -> f.urisAffected.size())
.sum();
}
}

0 comments on commit 471566c

Please # to comment.