From 295da29cd66b9035583206b5a1ccf184a0377448 Mon Sep 17 00:00:00 2001 From: Struchkov Mark Date: Wed, 21 Dec 2022 20:55:07 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B5=D0=B1=D0=BE=D0=BB=D1=8C=D1=88?= =?UTF-8?q?=D0=BE=D0=B9=20=D1=80=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE=D1=80?= =?UTF-8?q?=D0=B8=D0=BD=D0=B3=20=D1=80=D0=B5=D0=BF=D0=BE=D0=B7=D0=B8=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=B8=D0=B5=D0=B2=20=D0=B4=D0=BB=D1=8F=20MR?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../context/repository/MergeRequestRepository.java | 2 -- .../data/impl/MergeRequestRepositoryImpl.java | 13 ++++++++----- .../gitlab/data/jpa/MergeRequestJpaRepository.java | 12 ------------ gitlab-app/pom.xml | 4 ++++ 4 files changed, 12 insertions(+), 19 deletions(-) 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 +