improved code
This commit is contained in:
parent
bd1e1334ba
commit
b151cee04b
@ -14,6 +14,7 @@ import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -31,6 +32,11 @@ public class AutomaticAnalysisScheduler {
|
||||
private final ReanalysisRequiredStatusService reanalysisRequiredStatusService;
|
||||
private final AmqpAdmin amqpAdmin;
|
||||
|
||||
@PostConstruct
|
||||
protected void postConstruct() {
|
||||
log.info("Automatic Analysis pageFactor: {}", pageFactor);
|
||||
}
|
||||
|
||||
|
||||
@Scheduled(fixedDelay = 10000, initialDelay = 10000)
|
||||
public void checkFilesThatRequireReanalysisAndQueueIfPossible() {
|
||||
@ -53,12 +59,10 @@ public class AutomaticAnalysisScheduler {
|
||||
|
||||
while (worstCaseScenarioQueuedPages < pageFactor * consumerCount && allStatusesIterator.hasNext()) {
|
||||
var next = allStatusesIterator.next();
|
||||
if (next.isAnalysisRequired()) {
|
||||
// in case the file doesn't have numberOfPages set, we assume an average.
|
||||
worstCaseScenarioQueuedPages += next.getNumberOfPages() <= 0 ? pageFactor : next.getNumberOfPages();
|
||||
log.info("Queued file: {} for automatic analysis!", next.getFilename());
|
||||
fileStatusService.setStatusReprocess(next.getDossierId(), next.getId(), 1);
|
||||
}
|
||||
// in case the file doesn't have numberOfPages set, we assume an average.
|
||||
worstCaseScenarioQueuedPages += next.getNumberOfPages() <= 0 ? pageFactor : next.getNumberOfPages();
|
||||
log.info("Queued file: {} for automatic analysis!", next.getFilename());
|
||||
fileStatusService.setStatusReprocess(next.getDossierId(), next.getId(), 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,7 +79,7 @@ public class AutomaticAnalysisScheduler {
|
||||
.filter(f -> !f.getStatus().equals(FileStatus.DELETED))
|
||||
.filter(f -> !f.getStatus().equals(FileStatus.APPROVED))
|
||||
.filter(f -> !isProcessing(f))
|
||||
.collect(Collectors.toList()), FileModel.class, new FileModelMapper()));
|
||||
.collect(Collectors.toList()), FileModel.class, new FileModelMapper())).stream().filter(FileModel::isAnalysisRequired).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private boolean isProcessing(FileEntity file) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user