diff --git a/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/repository/MergeRequestRepository.java b/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/repository/MergeRequestRepository.java index 8a360a5..75f589b 100644 --- a/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/repository/MergeRequestRepository.java +++ b/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/repository/MergeRequestRepository.java @@ -22,8 +22,6 @@ public interface MergeRequestRepository { List findAllById(Set mergeRequestIds); - void deleteByIds(Set mergeRequestIds); - List findAllByReviewerId(Long personId); void deleteByStates(Set states); diff --git a/bot-data/src/main/java/dev/struchkov/bot/gitlab/data/impl/MergeRequestRepositoryImpl.java b/bot-data/src/main/java/dev/struchkov/bot/gitlab/data/impl/MergeRequestRepositoryImpl.java index c925fd0..15326c3 100644 --- a/bot-data/src/main/java/dev/struchkov/bot/gitlab/data/impl/MergeRequestRepositoryImpl.java +++ b/bot-data/src/main/java/dev/struchkov/bot/gitlab/data/impl/MergeRequestRepositoryImpl.java @@ -10,6 +10,7 @@ import dev.struchkov.bot.gitlab.data.jpa.MergeRequestJpaRepository; import lombok.NonNull; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Repository; +import org.springframework.transaction.annotation.Transactional; import java.util.List; import java.util.Optional; @@ -23,41 +24,43 @@ public class MergeRequestRepositoryImpl implements MergeRequestRepository { private final MergeRequestForDiscussionJpaRepository forDiscussionJpaRepository; @Override + @Transactional(readOnly = true) public Set findAllIdByStateIn(@NonNull Set statuses) { return jpaRepository.findAllIdByStateIn(statuses); } @Override + @Transactional public MergeRequest save(MergeRequest mergeRequest) { return jpaRepository.save(mergeRequest); } @Override + @Transactional(readOnly = true) public Optional findById(Long mergeRequestId) { return jpaRepository.findById(mergeRequestId); } @Override + @Transactional(readOnly = true) public List findAllForDiscussion() { return forDiscussionJpaRepository.findAll(); } @Override + @Transactional(readOnly = true) public List findAllById(Set mergeRequestIds) { return jpaRepository.findAllById(mergeRequestIds); } @Override - public void deleteByIds(Set mergeRequestIds) { - jpaRepository.deleteAllByIdIn(mergeRequestIds); - } - - @Override + @Transactional(readOnly = true) public List findAllByReviewerId(Long personId) { return jpaRepository.findAllByReviewersIn(personId); } @Override + @Transactional public void deleteByStates(Set states) { jpaRepository.deleteAllByStateIn(states); } diff --git a/bot-data/src/main/java/dev/struchkov/bot/gitlab/data/jpa/MergeRequestJpaRepository.java b/bot-data/src/main/java/dev/struchkov/bot/gitlab/data/jpa/MergeRequestJpaRepository.java index 9e9d0ba..9e9e8d3 100644 --- a/bot-data/src/main/java/dev/struchkov/bot/gitlab/data/jpa/MergeRequestJpaRepository.java +++ b/bot-data/src/main/java/dev/struchkov/bot/gitlab/data/jpa/MergeRequestJpaRepository.java @@ -7,9 +7,7 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.support.JpaRepositoryImplementation; import org.springframework.data.repository.query.Param; -import java.util.Collection; import java.util.List; -import java.util.Optional; import java.util.Set; /** @@ -18,19 +16,9 @@ import java.util.Set; public interface MergeRequestJpaRepository extends JpaRepositoryImplementation { - void deleteAllByIdIn(Collection id); - @Query("SELECT new dev.struchkov.bot.gitlab.context.domain.IdAndStatusPr(p.id, p.twoId, p.projectId, p.state) FROM MergeRequest p WHERE p.state IN :states") Set findAllIdByStateIn(@Param("states") Set states); - @Query("SELECT p.id FROM MergeRequest p") - Set findAllIds(); - - @Query("SELECT p.author.id FROM MergeRequest p WHERE p.id = :id") - Optional findAuthorById(@Param("id") Long id); - - List findAllByAssigneeId(Long userId); - @Query("SELECT mr FROM MergeRequest mr LEFT JOIN mr.reviewers r WHERE r.id = :reviewerId") List findAllByReviewersIn(@Param("reviewerId") Long reviewerId); diff --git a/gitlab-app/pom.xml b/gitlab-app/pom.xml index 0e3fed0..26024d4 100644 --- a/gitlab-app/pom.xml +++ b/gitlab-app/pom.xml @@ -56,6 +56,10 @@ org.springframework.boot spring-boot-starter + + org.springframework.boot + spring-boot-starter-actuator +