Skip to content

Commit

Permalink
Use one transaction for inserting status and results. (#35)
Browse files Browse the repository at this point in the history
* Use one transaction for inserting status and results.
  • Loading branch information
antoinebhs authored Sep 28, 2023
1 parent e50bb8b commit 3807023
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 @@ -111,12 +111,12 @@ 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));
}

@Transactional
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 3807023

Please sign in to comment.