From 06b4e0125a7b9ddd9bcc4de2c4f42bfffc7da004 Mon Sep 17 00:00:00 2001 From: Mohamed Bilel Besrour Date: Mon, 18 Nov 2024 22:57:20 +0100 Subject: [PATCH] remove useless code --- ...grammingExerciseBuildConfigRepository.java | 4 ---- .../ProgrammingSubmissionRepository.java | 14 ------------ .../service/ProgrammingMessagingService.java | 22 +++++++++---------- 3 files changed, 10 insertions(+), 30 deletions(-) diff --git a/src/main/java/de/tum/cit/aet/artemis/programming/repository/ProgrammingExerciseBuildConfigRepository.java b/src/main/java/de/tum/cit/aet/artemis/programming/repository/ProgrammingExerciseBuildConfigRepository.java index 03c67e704fe2..e543335002df 100644 --- a/src/main/java/de/tum/cit/aet/artemis/programming/repository/ProgrammingExerciseBuildConfigRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/programming/repository/ProgrammingExerciseBuildConfigRepository.java @@ -18,10 +18,6 @@ public interface ProgrammingExerciseBuildConfigRepository extends ArtemisJpaRepo Optional findByProgrammingExerciseId(Long programmingExerciseId); - default ProgrammingExerciseBuildConfig findByProgrammingExerciseIdElseThrow(Long programmingExerciseId) { - return getValueElseThrow(findByProgrammingExerciseId(programmingExerciseId), programmingExerciseId); - } - default ProgrammingExerciseBuildConfig getProgrammingExerciseBuildConfigElseThrow(ProgrammingExercise programmingExercise) { if (programmingExercise.getBuildConfig() == null || !Hibernate.isInitialized(programmingExercise.getBuildConfig())) { return getValueElseThrow(findByProgrammingExerciseId(programmingExercise.getId())); diff --git a/src/main/java/de/tum/cit/aet/artemis/programming/repository/ProgrammingSubmissionRepository.java b/src/main/java/de/tum/cit/aet/artemis/programming/repository/ProgrammingSubmissionRepository.java index ea0d9059b2f5..ffe438217b64 100644 --- a/src/main/java/de/tum/cit/aet/artemis/programming/repository/ProgrammingSubmissionRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/programming/repository/ProgrammingSubmissionRepository.java @@ -158,18 +158,4 @@ default ProgrammingSubmission findByIdWithResultsFeedbacksAssessorTestCases(long default ProgrammingSubmission findByResultIdElseThrow(long resultId) { return getValueElseThrow(findByResultId(resultId)); } - - @Query(""" - SELECT s - FROM ProgrammingSubmission s - LEFT JOIN FETCH s.participation p - WHERE p.id = :participationId - AND s.commitHash = :commitHash - ORDER BY s.id DESC - """) - List findByParticipationIdAndCommitHashOrderByIdDesc(@Param("participationId") long participationId, @Param("commitHash") String commitHash); - - default ProgrammingSubmission findFirstByParticipationIdAndCommitHashOrderByIdDesc(long participationId, String commitHash) { - return findByParticipationIdAndCommitHashOrderByIdDesc(participationId, commitHash).stream().findFirst().orElse(null); - } } diff --git a/src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingMessagingService.java b/src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingMessagingService.java index 98540e89874d..58b63fe716e0 100644 --- a/src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingMessagingService.java +++ b/src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingMessagingService.java @@ -84,18 +84,7 @@ public void notifyInstructorAboutCompletedExerciseBuildRun(ProgrammingExercise p * @param exerciseId used to build the correct topic */ public void notifyUserAboutSubmission(ProgrammingSubmission submission, Long exerciseId) { - notifyUserAboutSubmission(submission, exerciseId, false); - } - - /** - * Notify user on a new programming submission. - * - * @param submission ProgrammingSubmission - * @param exerciseId used to build the correct topic - * @param isProcessing whether the submission started processing or not - */ - public void notifyUserAboutSubmission(ProgrammingSubmission submission, Long exerciseId, boolean isProcessing) { - var submissionDTO = SubmissionDTO.of(submission, isProcessing, null, null); + var submissionDTO = SubmissionDTO.of(submission, false, null, null); if (submission.getParticipation() instanceof StudentParticipation studentParticipation) { if (studentParticipation.getParticipant() instanceof Team team) { // eager load the team with students so their information can be used for the messages below @@ -196,6 +185,15 @@ public void notifyUserAboutNewResult(Result result, ProgrammingExerciseParticipa } } + /** + * Notifies the user about the processing of a submission. + * This method sends a notification to the user that their submission is processing + * It handles both student participations and template/solution participations. + * + * @param submission the submission processing data transfer object containing the submission details + * @param exerciseId the ID of the exercise associated with the submission + * @param participationId the ID of the participation associated with the submission + */ public void notifyUserAboutSubmissionProcessing(SubmissionProcessingDTO submission, long exerciseId, long participationId) { Participation participation = participationRepository.findWithProgrammingExerciseWithBuildConfigById(participationId).orElseThrow(); if (participation instanceof StudentParticipation studentParticipation) {