Removed unused import, changed to save and flush submission during processing.

This commit is contained in:
Andrew Lalis 2023-01-30 08:18:09 +01:00
parent 75c0fdcff6
commit 1034f7e65a
2 changed files with 3 additions and 4 deletions

View File

@ -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;

View File

@ -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<ExerciseSubmissionTempFile> 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;
}