From 1034f7e65a2d46b0ada9f5220213f044cf88b4ab Mon Sep 17 00:00:00 2001 From: Andrew Lalis Date: Mon, 30 Jan 2023 08:18:09 +0100 Subject: [PATCH] Removed unused import, changed to save and flush submission during processing. --- .../andrewlalis/gymboard_api/controller/GymController.java | 1 - .../service/submission/SubmissionProcessingService.java | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/gymboard-api/src/main/java/nl/andrewlalis/gymboard_api/controller/GymController.java b/gymboard-api/src/main/java/nl/andrewlalis/gymboard_api/controller/GymController.java index 41dc25f..351fa94 100644 --- a/gymboard-api/src/main/java/nl/andrewlalis/gymboard_api/controller/GymController.java +++ b/gymboard-api/src/main/java/nl/andrewlalis/gymboard_api/controller/GymController.java @@ -2,7 +2,6 @@ package nl.andrewlalis.gymboard_api.controller; import nl.andrewlalis.gymboard_api.controller.dto.*; import nl.andrewlalis.gymboard_api.service.GymService; -import nl.andrewlalis.gymboard_api.service.LeaderboardService; import nl.andrewlalis.gymboard_api.service.UploadService; import nl.andrewlalis.gymboard_api.service.submission.ExerciseSubmissionService; import org.springframework.http.MediaType; diff --git a/gymboard-api/src/main/java/nl/andrewlalis/gymboard_api/service/submission/SubmissionProcessingService.java b/gymboard-api/src/main/java/nl/andrewlalis/gymboard_api/service/submission/SubmissionProcessingService.java index 200a639..8690662 100644 --- a/gymboard-api/src/main/java/nl/andrewlalis/gymboard_api/service/submission/SubmissionProcessingService.java +++ b/gymboard-api/src/main/java/nl/andrewlalis/gymboard_api/service/submission/SubmissionProcessingService.java @@ -90,7 +90,7 @@ public class SubmissionProcessingService { // Set the status to processing. submission.setStatus(ExerciseSubmission.Status.PROCESSING); - exerciseSubmissionRepository.save(submission); + exerciseSubmissionRepository.saveAndFlush(submission); // Then try and fetch the temporary video file associated with it. Optional optionalTempFile = tempFileRepository.findBySubmission(submission); @@ -105,7 +105,7 @@ public class SubmissionProcessingService { if (!Files.exists(tempFilePath) || !Files.isReadable(tempFilePath)) { log.error("Submission {} failed because the temporary video file {} isn't readable.", submission.getId(), tempFilePath); submission.setStatus(ExerciseSubmission.Status.FAILED); - exerciseSubmissionRepository.save(submission); + exerciseSubmissionRepository.saveAndFlush(submission); return; } @@ -135,7 +135,7 @@ public class SubmissionProcessingService { e.getMessage() ); submission.setStatus(ExerciseSubmission.Status.FAILED); - exerciseSubmissionRepository.save(submission); + exerciseSubmissionRepository.saveAndFlush(submission); return; }