Skip to content

Commit

Permalink
Development: Remove unused code, fix warnings and improve test code q…
Browse files Browse the repository at this point in the history
…uality
  • Loading branch information
krusche committed Nov 24, 2024
1 parent bd9295c commit dbb2e17
Show file tree
Hide file tree
Showing 22 changed files with 80 additions and 495 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ public CompetencyService(CompetencyRepository competencyRepository, Authorizatio
LearningObjectImportService learningObjectImportService, CompetencyLectureUnitLinkRepository competencyLectureUnitLinkRepository, CourseRepository courseRepository,
CompetencyExerciseLinkRepository competencyExerciseLinkRepository) {
super(competencyProgressRepository, courseCompetencyRepository, competencyRelationRepository, competencyProgressService, exerciseService, lectureUnitService,
learningPathService, authCheckService, standardizedCompetencyRepository, lectureUnitCompletionRepository, learningObjectImportService,
competencyLectureUnitLinkRepository, courseRepository);
learningPathService, authCheckService, standardizedCompetencyRepository, lectureUnitCompletionRepository, learningObjectImportService, courseRepository);
this.competencyRepository = competencyRepository;
this.competencyExerciseLinkRepository = competencyExerciseLinkRepository;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import de.tum.cit.aet.artemis.atlas.dto.CompetencyRelationDTO;
import de.tum.cit.aet.artemis.atlas.dto.CompetencyWithTailRelationDTO;
import de.tum.cit.aet.artemis.atlas.dto.UpdateCourseCompetencyRelationDTO;
import de.tum.cit.aet.artemis.atlas.repository.CompetencyLectureUnitLinkRepository;
import de.tum.cit.aet.artemis.atlas.repository.CompetencyProgressRepository;
import de.tum.cit.aet.artemis.atlas.repository.CompetencyRelationRepository;
import de.tum.cit.aet.artemis.atlas.repository.CourseCompetencyRepository;
Expand Down Expand Up @@ -83,15 +82,13 @@ public class CourseCompetencyService {

private final LearningObjectImportService learningObjectImportService;

private final CompetencyLectureUnitLinkRepository competencyLectureUnitLinkRepository;

private final CourseRepository courseRepository;

public CourseCompetencyService(CompetencyProgressRepository competencyProgressRepository, CourseCompetencyRepository courseCompetencyRepository,
CompetencyRelationRepository competencyRelationRepository, CompetencyProgressService competencyProgressService, ExerciseService exerciseService,
LectureUnitService lectureUnitService, LearningPathService learningPathService, AuthorizationCheckService authCheckService,
StandardizedCompetencyRepository standardizedCompetencyRepository, LectureUnitCompletionRepository lectureUnitCompletionRepository,
LearningObjectImportService learningObjectImportService, CompetencyLectureUnitLinkRepository competencyLectureUnitLinkRepository, CourseRepository courseRepository) {
LearningObjectImportService learningObjectImportService, CourseRepository courseRepository) {
this.competencyProgressRepository = competencyProgressRepository;
this.courseCompetencyRepository = courseCompetencyRepository;
this.competencyRelationRepository = competencyRelationRepository;
Expand All @@ -103,7 +100,6 @@ public CourseCompetencyService(CompetencyProgressRepository competencyProgressRe
this.standardizedCompetencyRepository = standardizedCompetencyRepository;
this.lectureUnitCompletionRepository = lectureUnitCompletionRepository;
this.learningObjectImportService = learningObjectImportService;
this.competencyLectureUnitLinkRepository = competencyLectureUnitLinkRepository;
this.courseRepository = courseRepository;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ public PrerequisiteService(PrerequisiteRepository prerequisiteRepository, Author
StandardizedCompetencyRepository standardizedCompetencyRepository, CourseCompetencyRepository courseCompetencyRepository, ExerciseService exerciseService,
LearningObjectImportService learningObjectImportService, CompetencyLectureUnitLinkRepository competencyLectureUnitLinkRepository, CourseRepository courseRepository) {
super(competencyProgressRepository, courseCompetencyRepository, competencyRelationRepository, competencyProgressService, exerciseService, lectureUnitService,
learningPathService, authCheckService, standardizedCompetencyRepository, lectureUnitCompletionRepository, learningObjectImportService,
competencyLectureUnitLinkRepository, courseRepository);
learningPathService, authCheckService, standardizedCompetencyRepository, lectureUnitCompletionRepository, learningObjectImportService, courseRepository);
this.prerequisiteRepository = prerequisiteRepository;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,21 +137,4 @@ default Post findMessagePostByIdElseThrow(Long postId) throws EntityNotFoundExce
WHERE p.id = :postId AND answer.author = cp.user
""")
Set<User> findUsersWhoRepliedInMessage(@Param("postId") Long postId);

/**
* Finds tags of course-wide messages
*
* @param courseId the course
* @return list of tags
*/
// TODO: unused, delete
@Query("""
SELECT DISTINCT tag
FROM Post post
LEFT JOIN post.tags tag
LEFT JOIN Channel channel ON channel.id = post.conversation.id
WHERE channel.course.id = :courseId
AND channel.isCourseWide = TRUE
""")
List<String> findPostTagsForCourse(@Param("courseId") Long courseId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE;

import java.time.ZonedDateTime;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
Expand All @@ -24,8 +22,6 @@
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import com.google.common.collect.Lists;

import de.tum.cit.aet.artemis.communication.domain.ConversationNotificationRecipientSummary;
import de.tum.cit.aet.artemis.communication.domain.CreatedConversationMessage;
import de.tum.cit.aet.artemis.communication.domain.DisplayPriority;
Expand All @@ -49,7 +45,6 @@
import de.tum.cit.aet.artemis.communication.service.conversation.auth.ChannelAuthorizationService;
import de.tum.cit.aet.artemis.communication.service.notifications.ConversationNotificationService;
import de.tum.cit.aet.artemis.communication.service.notifications.GroupNotificationService;
import de.tum.cit.aet.artemis.communication.service.similarity.PostSimilarityComparisonStrategy;
import de.tum.cit.aet.artemis.core.domain.Course;
import de.tum.cit.aet.artemis.core.domain.User;
import de.tum.cit.aet.artemis.core.exception.AccessForbiddenException;
Expand All @@ -66,8 +61,6 @@
@Service
public class ConversationMessagingService extends PostingService {

private static final int TOP_K_SIMILARITY_RESULTS = 5;

private static final Logger log = LoggerFactory.getLogger(ConversationMessagingService.class);

private final ConversationService conversationService;
Expand All @@ -82,22 +75,18 @@ public class ConversationMessagingService extends PostingService {

private final SingleUserNotificationRepository singleUserNotificationRepository;

private final PostSimilarityComparisonStrategy postContentCompareStrategy;

protected ConversationMessagingService(CourseRepository courseRepository, ExerciseRepository exerciseRepository, LectureRepository lectureRepository,
ConversationMessageRepository conversationMessageRepository, AuthorizationCheckService authorizationCheckService, WebsocketMessagingService websocketMessagingService,
UserRepository userRepository, ConversationService conversationService, ConversationParticipantRepository conversationParticipantRepository,
ConversationNotificationService conversationNotificationService, ChannelAuthorizationService channelAuthorizationService,
GroupNotificationService groupNotificationService, SingleUserNotificationRepository singleUserNotificationRepository,
PostSimilarityComparisonStrategy postContentCompareStrategy) {
GroupNotificationService groupNotificationService, SingleUserNotificationRepository singleUserNotificationRepository) {
super(courseRepository, userRepository, exerciseRepository, lectureRepository, authorizationCheckService, websocketMessagingService, conversationParticipantRepository);
this.conversationService = conversationService;
this.conversationMessageRepository = conversationMessageRepository;
this.conversationNotificationService = conversationNotificationService;
this.channelAuthorizationService = channelAuthorizationService;
this.groupNotificationService = groupNotificationService;
this.singleUserNotificationRepository = singleUserNotificationRepository;
this.postContentCompareStrategy = postContentCompareStrategy;
}

/**
Expand Down Expand Up @@ -433,41 +422,6 @@ private Conversation mayUpdateOrDeleteMessageElseThrow(Post existingMessagePost,
}
}

/**
* Calculates k similar posts based on the underlying content comparison strategy
*
* @param courseId id of the course in which similar posts are searched for
* @param post post that is to be created and check for similar posts beforehand
* @return list of similar posts
*/
// TODO: unused, remove
public List<Post> getSimilarPosts(Long courseId, Post post) {
PostContextFilterDTO postContextFilter = new PostContextFilterDTO(courseId, null, null, null, null, false, false, false, null, null);
List<Post> coursePosts = this.getCourseWideMessages(Pageable.unpaged(), postContextFilter, userRepository.getUser(), courseId).stream()
.sorted(Comparator.comparing(coursePost -> postContentCompareStrategy.performSimilarityCheck(post, coursePost))).toList();

// sort course posts by calculated similarity scores
setAuthorRoleOfPostings(coursePosts, courseId);
return Lists.reverse(coursePosts).stream().limit(TOP_K_SIMILARITY_RESULTS).toList();
}

/**
* Checks course and user validity,
* retrieves all tags for posts in a certain course
*
* @param courseId id of the course the tags belongs to
* @return tags of all posts that belong to the course
*/
// TODO: unused, delete
public List<String> getAllCourseTags(Long courseId) {
final User user = userRepository.getUserWithGroupsAndAuthorities();
final Course course = courseRepository.findByIdElseThrow(courseId);

// checks
preCheckUserAndCourseForCommunicationOrMessaging(user, course);
return conversationMessageRepository.findPostTagsForCourse(courseId);
}

@Override
public String getEntityName() {
return METIS_POST_ENTITY_NAME;
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -201,34 +201,4 @@ public ResponseEntity<Post> updateDisplayPriority(@PathVariable Long courseId, @
Post postWithUpdatedDisplayPriority = conversationMessagingService.changeDisplayPriority(courseId, postId, displayPriority);
return ResponseEntity.ok().body(postWithUpdatedDisplayPriority);
}

/**
* POST /courses/{courseId}/messages/similarity-check : trigger a similarity check for post to be created
*
* @param courseId id of the course the post should be published in
* @param post post to create
* @return ResponseEntity with status 200 (OK)
*/
@PostMapping("courses/{courseId}/messages/similarity-check")
@EnforceAtLeastStudent
// TODO: unused, remove
public ResponseEntity<List<Post>> computeSimilarityScoresWitCoursePosts(@PathVariable Long courseId, @RequestBody Post post) {
List<Post> similarPosts = conversationMessagingService.getSimilarPosts(courseId, post);
return ResponseEntity.ok().body(similarPosts);
}

/**
* GET /courses/{courseId}/posts/tags : Get all tags for posts in a certain course
*
* @param courseId id of the course the post belongs to
* @return the ResponseEntity with status 200 (OK) and with body all tags for posts in that course,
* or 400 (Bad Request) if the checks on user or course validity fail
*/
@GetMapping("courses/{courseId}/messages/tags")
// TODO: unused, delete
@EnforceAtLeastStudent
public ResponseEntity<List<String>> getAllPostTagsForCourse(@PathVariable Long courseId) {
List<String> tags = conversationMessagingService.getAllCourseTags(courseId);
return new ResponseEntity<>(tags, null, HttpStatus.OK);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

import de.tum.cit.aet.artemis.assessment.repository.cleanup.FeedbackCleanupRepository;
import de.tum.cit.aet.artemis.assessment.repository.cleanup.LongFeedbackTextCleanupRepository;
import de.tum.cit.aet.artemis.assessment.repository.cleanup.ParticipantScoreCleanupRepository;
import de.tum.cit.aet.artemis.assessment.repository.cleanup.PlagiarismComparisonCleanupRepository;
import de.tum.cit.aet.artemis.assessment.repository.cleanup.RatingCleanupRepository;
import de.tum.cit.aet.artemis.assessment.repository.cleanup.ResultCleanupRepository;
Expand Down Expand Up @@ -49,13 +48,10 @@ public class DataCleanupService {

private final TeamScoreCleanupRepository teamScoreCleanupRepository;

private final ParticipantScoreCleanupRepository participantScoreCleanupRepository;

public DataCleanupService(CleanupJobExecutionRepository cleanupJobExecutionRepository, PlagiarismComparisonCleanupRepository plagiarismComparisonCleanupRepository,
ResultCleanupRepository resultCleanupRepository, RatingCleanupRepository ratingCleanupRepository, FeedbackCleanupRepository feedbackCleanupRepository,
TextBlockCleanupRepository textBlockCleanupRepository, LongFeedbackTextCleanupRepository longFeedbackTextCleanupRepository,
StudentScoreCleanupRepository studentScoreCleanupRepository, TeamScoreCleanupRepository teamScoreCleanupRepository,
ParticipantScoreCleanupRepository participantScoreCleanupRepository) {
StudentScoreCleanupRepository studentScoreCleanupRepository, TeamScoreCleanupRepository teamScoreCleanupRepository) {
this.resultCleanupRepository = resultCleanupRepository;
this.ratingCleanupRepository = ratingCleanupRepository;
this.feedbackCleanupRepository = feedbackCleanupRepository;
Expand All @@ -65,7 +61,6 @@ public DataCleanupService(CleanupJobExecutionRepository cleanupJobExecutionRepos
this.teamScoreCleanupRepository = teamScoreCleanupRepository;
this.cleanupJobExecutionRepository = cleanupJobExecutionRepository;
this.plagiarismComparisonCleanupRepository = plagiarismComparisonCleanupRepository;
this.participantScoreCleanupRepository = participantScoreCleanupRepository;
}

// TODO: offer the possibility to delete old submission versions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import de.tum.cit.aet.artemis.communication.service.WebsocketMessagingService;
import de.tum.cit.aet.artemis.core.domain.User;
import de.tum.cit.aet.artemis.core.repository.UserRepository;
import de.tum.cit.aet.artemis.exam.domain.Exam;
import de.tum.cit.aet.artemis.exam.domain.StudentExam;
import de.tum.cit.aet.artemis.exam.domain.event.ExamAttendanceCheckEvent;
Expand Down Expand Up @@ -55,14 +54,11 @@ public class ExamLiveEventsService {

private final StudentExamRepository studentExamRepository;

private final UserRepository userRepository;

public ExamLiveEventsService(WebsocketMessagingService websocketMessagingService, ExamLiveEventRepository examLiveEventRepository, StudentExamRepository studentExamRepository,
UserRepository userRepository) {
public ExamLiveEventsService(WebsocketMessagingService websocketMessagingService, ExamLiveEventRepository examLiveEventRepository,
StudentExamRepository studentExamRepository) {
this.websocketMessagingService = websocketMessagingService;
this.examLiveEventRepository = examLiveEventRepository;
this.studentExamRepository = studentExamRepository;
this.userRepository = userRepository;
}

/**
Expand Down
Loading

0 comments on commit dbb2e17

Please sign in to comment.