Skip to content

Commit

Permalink
Use one transaction for inserting status and results.
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinebhs committed Sep 20, 2023
1 parent fbdd8fc commit be94cd7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ public void insertStatus(List<UUID> resultUuids, String status) {
}

@Transactional
public void insert(UUID resultUuid, SensitivityAnalysisResult result) {
public void insert(UUID resultUuid, SensitivityAnalysisResult result, String status) {
Objects.requireNonNull(resultUuid);

if (result != null) {
analysisResultRepository.save(toAnalysisResultEntity(resultUuid, result));
globalStatusRepository.save(toStatusEntity(resultUuid, status));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,7 @@ public Consumer<Message<String>> consumeRun() {
long nanoTime = System.nanoTime();
LOGGER.info("Just run in {}s", TimeUnit.NANOSECONDS.toSeconds(nanoTime - startTime.getAndSet(nanoTime)));

resultRepository.insert(resultContext.getResultUuid(), result);
resultRepository.insertStatus(List.of(resultContext.getResultUuid()), SensitivityAnalysisStatus.COMPLETED.name());
resultRepository.insert(resultContext.getResultUuid(), result, SensitivityAnalysisStatus.COMPLETED.name());
long finalNanoTime = System.nanoTime();
LOGGER.info("Stored in {}s", TimeUnit.NANOSECONDS.toSeconds(finalNanoTime - startTime.getAndSet(finalNanoTime)));

Expand Down

0 comments on commit be94cd7

Please sign in to comment.