diff --git a/bot-app/src/main/java/org/sadtech/bot/gitlab/app/scheduler/SchedulerService.java b/bot-app/src/main/java/org/sadtech/bot/gitlab/app/scheduler/SchedulerService.java
index 8e6b417..7d15801 100644
--- a/bot-app/src/main/java/org/sadtech/bot/gitlab/app/scheduler/SchedulerService.java
+++ b/bot-app/src/main/java/org/sadtech/bot/gitlab/app/scheduler/SchedulerService.java
@@ -2,6 +2,7 @@ package org.sadtech.bot.gitlab.app.scheduler;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
+import org.sadtech.bot.gitlab.context.service.CleanService;
import org.sadtech.bot.gitlab.core.service.parser.MergeRequestParser;
import org.sadtech.bot.gitlab.core.service.parser.NoteParser;
import org.sadtech.bot.gitlab.core.service.parser.PipelineParser;
@@ -21,6 +22,7 @@ public class SchedulerService {
private final PipelineParser pipelineParser;
private final MergeRequestParser mergeRequestParser;
private final NoteParser noteParser;
+ private final CleanService cleanService;
@Scheduled(cron = "*/30 * * * * *")
public void newMergeRequest() {
@@ -52,4 +54,10 @@ public class SchedulerService {
pipelineParser.scanOldPipeline();
}
+ @Scheduled(cron = "0 */1 * * * *")
+ public void clean() {
+ cleanService.cleanOldPipelines();
+ cleanService.cleanMergedPullRequests();
+ }
+
}
diff --git a/bot-app/src/main/resources/public/index.html b/bot-app/src/main/resources/public/index.html
deleted file mode 100644
index 3b495f9..0000000
--- a/bot-app/src/main/resources/public/index.html
+++ /dev/null
@@ -1,68 +0,0 @@
-
-
-
-
-
-
-
- Авторизатор BitbucketBot
-
-
-
-
-
-
-
-
diff --git a/bot-app/src/main/resources/public/static/css/signin.css b/bot-app/src/main/resources/public/static/css/signin.css
deleted file mode 100644
index 4523a87..0000000
--- a/bot-app/src/main/resources/public/static/css/signin.css
+++ /dev/null
@@ -1,50 +0,0 @@
-html,
-body {
- height: 100%;
-}
-
-body {
- display: -ms-flexbox;
- display: -webkit-box;
- display: flex;
- -ms-flex-align: center;
- -ms-flex-pack: center;
- -webkit-box-align: center;
- align-items: center;
- -webkit-box-pack: center;
- justify-content: center;
- padding-top: 40px;
- padding-bottom: 40px;
- background-color: #f5f5f5;
-}
-
-.form-signin {
- width: 100%;
- max-width: 330px;
- padding: 15px;
- margin: 0 auto;
-}
-.form-signin .checkbox {
- font-weight: 400;
-}
-.form-signin .form-control {
- margin: 10px;
- position: relative;
- box-sizing: border-box;
- height: auto;
- padding: 10px;
- font-size: 16px;
-}
-.form-signin .form-control:focus {
- z-index: 2;
-}
-.form-signin input[type="email"] {
- margin-bottom: -1px;
- border-bottom-right-radius: 0;
- border-bottom-left-radius: 0;
-}
-.form-signin input[type="password"] {
- margin-bottom: 10px;
- border-top-left-radius: 0;
- border-top-right-radius: 0;
-}
diff --git a/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/entity/MergeRequest.java b/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/entity/MergeRequest.java
index 8658518..3101388 100644
--- a/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/entity/MergeRequest.java
+++ b/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/entity/MergeRequest.java
@@ -12,12 +12,17 @@ import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
+import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
import javax.persistence.Table;
import java.time.LocalDateTime;
+import java.util.ArrayList;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
/**
@@ -90,8 +95,8 @@ public class MergeRequest implements BasicEntity {
@Column(name = "date_last_commit")
private LocalDateTime dateLastCommit;
-// @JoinTable
-// @OneToMany(fetch = FetchType.LAZY)
-// private List notes = new ArrayList<>();
+ @JoinTable
+ @OneToMany(fetch = FetchType.LAZY, orphanRemoval = true)
+ private List notes = new ArrayList<>();
}
diff --git a/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/filter/PipelineFilter.java b/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/filter/PipelineFilter.java
new file mode 100644
index 0000000..5f80c49
--- /dev/null
+++ b/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/filter/PipelineFilter.java
@@ -0,0 +1,26 @@
+package org.sadtech.bot.gitlab.context.domain.filter;
+
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+import java.time.LocalDateTime;
+
+/**
+ * // TODO: 08.02.2021 Добавить описание.
+ *
+ * @author upagge 08.02.2021
+ */
+@Getter
+@Setter
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor(access = AccessLevel.PRIVATE)
+public class PipelineFilter {
+
+ private LocalDateTime lessThanCreatedDate;
+
+}
diff --git a/bot-context/src/main/java/org/sadtech/bot/gitlab/context/repository/PipelineRepository.java b/bot-context/src/main/java/org/sadtech/bot/gitlab/context/repository/PipelineRepository.java
index 26780e9..c3b03c7 100644
--- a/bot-context/src/main/java/org/sadtech/bot/gitlab/context/repository/PipelineRepository.java
+++ b/bot-context/src/main/java/org/sadtech/bot/gitlab/context/repository/PipelineRepository.java
@@ -6,6 +6,7 @@ import org.sadtech.bot.gitlab.context.domain.entity.Pipeline;
import org.sadtech.haiti.context.page.Pagination;
import org.sadtech.haiti.context.page.Sheet;
import org.sadtech.haiti.context.repository.SimpleManagerRepository;
+import org.sadtech.haiti.filter.FilterOperation;
import java.util.Set;
@@ -14,7 +15,7 @@ import java.util.Set;
*
* @author upagge 17.01.2021
*/
-public interface PipelineRepository extends SimpleManagerRepository {
+public interface PipelineRepository extends SimpleManagerRepository, FilterOperation {
Sheet findAllByStatuses(@NonNull Set statuses, @NonNull Pagination pagination);
}
diff --git a/bot-context/src/main/java/org/sadtech/bot/gitlab/context/service/CleanService.java b/bot-context/src/main/java/org/sadtech/bot/gitlab/context/service/CleanService.java
new file mode 100644
index 0000000..0ef0971
--- /dev/null
+++ b/bot-context/src/main/java/org/sadtech/bot/gitlab/context/service/CleanService.java
@@ -0,0 +1,14 @@
+package org.sadtech.bot.gitlab.context.service;
+
+/**
+ * // TODO: 08.02.2021 Добавить описание.
+ *
+ * @author upagge 08.02.2021
+ */
+public interface CleanService {
+
+ void cleanMergedPullRequests();
+
+ void cleanOldPipelines();
+
+}
diff --git a/bot-context/src/main/java/org/sadtech/bot/gitlab/context/service/MergeRequestsService.java b/bot-context/src/main/java/org/sadtech/bot/gitlab/context/service/MergeRequestsService.java
index db25199..a3380f0 100644
--- a/bot-context/src/main/java/org/sadtech/bot/gitlab/context/service/MergeRequestsService.java
+++ b/bot-context/src/main/java/org/sadtech/bot/gitlab/context/service/MergeRequestsService.java
@@ -7,7 +7,6 @@ import org.sadtech.bot.gitlab.context.domain.filter.MergeRequestFilter;
import org.sadtech.haiti.context.service.SimpleManagerService;
import org.sadtech.haiti.filter.FilterService;
-import java.util.List;
import java.util.Set;
public interface MergeRequestsService extends SimpleManagerService, FilterService {
@@ -20,6 +19,4 @@ public interface MergeRequestsService extends SimpleManagerService getAllId(Set statuses);
- List getAllByAssignee(Long userId);
-
}
diff --git a/bot-context/src/main/java/org/sadtech/bot/gitlab/context/service/PipelineService.java b/bot-context/src/main/java/org/sadtech/bot/gitlab/context/service/PipelineService.java
index 2863c6c..47e0988 100644
--- a/bot-context/src/main/java/org/sadtech/bot/gitlab/context/service/PipelineService.java
+++ b/bot-context/src/main/java/org/sadtech/bot/gitlab/context/service/PipelineService.java
@@ -3,9 +3,11 @@ package org.sadtech.bot.gitlab.context.service;
import lombok.NonNull;
import org.sadtech.bot.gitlab.context.domain.PipelineStatus;
import org.sadtech.bot.gitlab.context.domain.entity.Pipeline;
+import org.sadtech.bot.gitlab.context.domain.filter.PipelineFilter;
import org.sadtech.haiti.context.page.Pagination;
import org.sadtech.haiti.context.page.Sheet;
import org.sadtech.haiti.context.service.SimpleManagerService;
+import org.sadtech.haiti.filter.FilterService;
import java.util.Set;
@@ -14,7 +16,7 @@ import java.util.Set;
*
* @author upagge 17.01.2021
*/
-public interface PipelineService extends SimpleManagerService {
+public interface PipelineService extends SimpleManagerService, FilterService {
Sheet getAllByStatuses(@NonNull Set statuses, @NonNull Pagination pagination);
diff --git a/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/CleanServiceImpl.java b/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/CleanServiceImpl.java
new file mode 100644
index 0000000..27541eb
--- /dev/null
+++ b/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/CleanServiceImpl.java
@@ -0,0 +1,79 @@
+package org.sadtech.bot.gitlab.core.service.impl;
+
+import lombok.RequiredArgsConstructor;
+import org.sadtech.bot.gitlab.context.domain.entity.MergeRequest;
+import org.sadtech.bot.gitlab.context.domain.entity.Pipeline;
+import org.sadtech.bot.gitlab.context.domain.filter.MergeRequestFilter;
+import org.sadtech.bot.gitlab.context.domain.filter.PipelineFilter;
+import org.sadtech.bot.gitlab.context.service.CleanService;
+import org.sadtech.bot.gitlab.context.service.MergeRequestsService;
+import org.sadtech.bot.gitlab.context.service.PipelineService;
+import org.sadtech.haiti.context.page.Sheet;
+import org.sadtech.haiti.core.page.PaginationImpl;
+import org.springframework.stereotype.Service;
+
+import java.time.LocalDateTime;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static org.sadtech.bot.gitlab.context.domain.MergeRequestState.CLOSED;
+import static org.sadtech.bot.gitlab.context.domain.MergeRequestState.MERGED;
+
+/**
+ * // TODO: 08.02.2021 Добавить описание.
+ *
+ * @author upagge 08.02.2021
+ */
+@Service
+@RequiredArgsConstructor
+public class CleanServiceImpl implements CleanService {
+
+ private static final int COUNT = 1000;
+ private static final MergeRequestFilter CLEAN_FILTER = MergeRequestFilter.builder()
+ .states(Stream.of(MERGED, CLOSED).collect(Collectors.toSet()))
+ .build();
+
+ private final MergeRequestsService mergeRequestsService;
+ private final PipelineService pipelineService;
+
+ @Override
+ public void cleanMergedPullRequests() {
+ int page = 0;
+ Sheet mergeRequestSheet = mergeRequestsService.getAll(CLEAN_FILTER, PaginationImpl.of(page, COUNT));
+
+ while (mergeRequestSheet.hasContent()) {
+ final Set ids = mergeRequestSheet.getContent().stream()
+ .map(MergeRequest::getId)
+ .collect(Collectors.toSet());
+
+ mergeRequestsService.deleteAllById(ids);
+
+ mergeRequestSheet = mergeRequestsService.getAll(CLEAN_FILTER, PaginationImpl.of(++page, COUNT));
+ }
+ }
+
+ @Override
+ public void cleanOldPipelines() {
+ int page = 0;
+ final PipelineFilter filter = cleanPipelineFilter();
+ Sheet sheet = pipelineService.getAll(filter, PaginationImpl.of(page, COUNT));
+
+ while (sheet.hasContent()) {
+ final Set ids = sheet.getContent().stream()
+ .map(Pipeline::getId)
+ .collect(Collectors.toSet());
+
+ pipelineService.deleteAllById(ids);
+
+ sheet = pipelineService.getAll(filter, PaginationImpl.of(page, COUNT));
+ }
+ }
+
+ private PipelineFilter cleanPipelineFilter() {
+ final PipelineFilter pipelineFilter = new PipelineFilter();
+ pipelineFilter.setLessThanCreatedDate(LocalDateTime.now().minusDays(1L));
+ return pipelineFilter;
+ }
+
+}
diff --git a/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/MergeRequestsServiceImpl.java b/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/MergeRequestsServiceImpl.java
index 56ba354..f904875 100644
--- a/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/MergeRequestsServiceImpl.java
+++ b/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/MergeRequestsServiceImpl.java
@@ -24,7 +24,6 @@ import org.sadtech.haiti.filter.FilterService;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
-import java.util.List;
import java.util.Optional;
import java.util.Set;
@@ -96,11 +95,12 @@ public class MergeRequestsServiceImpl extends AbstractSimpleManagerService new NotFoundException("МержРеквест не найден"));
-// forgottenNotification(oldMergeRequest);
-
if (mergeRequest.getNotification() == null) {
mergeRequest.setNotification(oldMergeRequest.getNotification());
}
@@ -136,31 +136,6 @@ public class MergeRequestsServiceImpl extends AbstractSimpleManagerService smartReviewers = mergeRequest.getReviewers().stream()
-// .filter(
-// reviewer -> ReviewerStatus.NEEDS_WORK.equals(reviewer.getStatus())
-// && LocalDateTime.now().isAfter(reviewer.getDateChange().plusHours(2L))
-// && reviewer.getDateSmartNotify() == null
-// )
-// .peek(reviewer -> reviewer.setDateSmartNotify(LocalDateTime.now()))
-// .map(Reviewer::getPersonLogin)
-// .collect(Collectors.toSet());
-// if (!smartReviewers.isEmpty()) {
-// notifyService.send(
-// ForgottenSmartPrNotify.builder()
-// .projectKey(mergeRequest.getProjectKey())
-// .repositorySlug(mergeRequest.getRepositorySlug())
-// .recipients(smartReviewers)
-// .title(mergeRequest.getTitle())
-// .url(mergeRequest.getUrl())
-// .build()
-// );
-// }
-// }
- }
-
protected void notifyConflict(MergeRequest oldMergeRequest, MergeRequest mergeRequest, Project project) {
if (
!oldMergeRequest.isConflict()
@@ -201,11 +176,6 @@ public class MergeRequestsServiceImpl extends AbstractSimpleManagerService getAllByAssignee(@NonNull Long userId) {
- return mergeRequestRepository.findAllByAssignee(userId);
- }
-
@Override
public Sheet getAll(@NonNull MergeRequestFilter filter, Pagination pagination) {
return filterService.getAll(filter, pagination);
diff --git a/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/PipelineServiceImpl.java b/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/PipelineServiceImpl.java
index e6d6b41..5ccc1bc 100644
--- a/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/PipelineServiceImpl.java
+++ b/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/PipelineServiceImpl.java
@@ -4,17 +4,20 @@ import lombok.NonNull;
import org.sadtech.bot.gitlab.context.domain.PersonInformation;
import org.sadtech.bot.gitlab.context.domain.PipelineStatus;
import org.sadtech.bot.gitlab.context.domain.entity.Pipeline;
+import org.sadtech.bot.gitlab.context.domain.filter.PipelineFilter;
import org.sadtech.bot.gitlab.context.domain.notify.pipeline.PipelineNotify;
import org.sadtech.bot.gitlab.context.repository.PipelineRepository;
import org.sadtech.bot.gitlab.context.service.NotifyService;
import org.sadtech.bot.gitlab.context.service.PersonService;
import org.sadtech.bot.gitlab.context.service.PipelineService;
+import org.sadtech.bot.gitlab.core.service.impl.filter.PipelineFilterService;
import org.sadtech.haiti.context.exception.NotFoundException;
import org.sadtech.haiti.context.page.Pagination;
import org.sadtech.haiti.context.page.Sheet;
import org.sadtech.haiti.core.service.AbstractSimpleManagerService;
import org.springframework.stereotype.Service;
+import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -39,14 +42,16 @@ public class PipelineServiceImpl extends AbstractSimpleManagerService getAllByStatuses(@NonNull Set statuses, @NonNull Pagination pagination) {
return repository.findAllByStatuses(statuses, pagination);
}
+
+ @Override
+ public Sheet getAll(@NonNull PipelineFilter filter, @NonNull Pagination pagination) {
+ return pipelineFilterService.getAll(filter, pagination);
+ }
+
+ @Override
+ public Optional getFirst(@NonNull PipelineFilter filter) {
+ return pipelineFilterService.getFirst(filter);
+ }
+
+ @Override
+ public boolean exists(@NonNull PipelineFilter filter) {
+ return pipelineFilterService.exists(filter);
+ }
+
+ @Override
+ public long count(@NonNull PipelineFilter filter) {
+ return pipelineFilterService.count(filter);
+ }
}
diff --git a/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/filter/MergeRequestFilterService.java b/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/filter/MergeRequestFilterService.java
index ab435ab..c7548f7 100644
--- a/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/filter/MergeRequestFilterService.java
+++ b/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/filter/MergeRequestFilterService.java
@@ -22,15 +22,18 @@ public class MergeRequestFilterService extends AbstractFilterServicecreate()
- .and(
- convertFilter(filter)
- );
+ .and(convertFilter(filter))
+ .or(convertFilterOr(filter));
+ }
+
+ private FilterQuery convertFilterOr(MergeRequestFilter filter) {
+ return CriteriaQuery.create()
+ .matchPhrase(MergeRequest_.STATE, filter.getStates());
}
private FilterQuery convertFilter(@NonNull MergeRequestFilter filter) {
return CriteriaQuery.create()
- .matchPhrase(MergeRequest_.ASSIGNEE, filter.getAssignee())
- .matchPhrase(MergeRequest_.STATE, filter.getStates());
+ .matchPhrase(MergeRequest_.ASSIGNEE, filter.getAssignee());
}
}
diff --git a/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/filter/PipelineFilterService.java b/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/filter/PipelineFilterService.java
new file mode 100644
index 0000000..444f6be
--- /dev/null
+++ b/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/filter/PipelineFilterService.java
@@ -0,0 +1,37 @@
+package org.sadtech.bot.gitlab.core.service.impl.filter;
+
+import lombok.NonNull;
+import org.sadtech.bot.gitlab.context.domain.entity.Pipeline;
+import org.sadtech.bot.gitlab.context.domain.entity.Pipeline_;
+import org.sadtech.bot.gitlab.context.domain.filter.PipelineFilter;
+import org.sadtech.bot.gitlab.context.repository.PipelineRepository;
+import org.sadtech.haiti.core.service.AbstractFilterService;
+import org.sadtech.haiti.filter.Filter;
+import org.sadtech.haiti.filter.FilterQuery;
+import org.sadtech.haiti.filter.criteria.CriteriaFilter;
+import org.sadtech.haiti.filter.criteria.CriteriaQuery;
+import org.springframework.stereotype.Service;
+
+/**
+ * // TODO: 08.02.2021 Добавить описание.
+ *
+ * @author upagge 08.02.2021
+ */
+@Service
+public class PipelineFilterService extends AbstractFilterService {
+
+ public PipelineFilterService(PipelineRepository pipelineRepository) {
+ super(pipelineRepository);
+ }
+
+ @Override
+ protected Filter createFilter(@NonNull PipelineFilter pipelineFilter) {
+ return CriteriaFilter.create()
+ .and(convertAnd(pipelineFilter));
+ }
+
+ private FilterQuery convertAnd(PipelineFilter pipelineFilter) {
+ return CriteriaQuery.create()
+ .lessThan(Pipeline_.CREATED, pipelineFilter.getLessThanCreatedDate());
+ }
+}
diff --git a/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/note/TaskServiceImpl.java b/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/note/TaskServiceImpl.java
index 1381c2e..f1be6b0 100644
--- a/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/note/TaskServiceImpl.java
+++ b/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/note/TaskServiceImpl.java
@@ -90,7 +90,9 @@ public class TaskServiceImpl extends AbstractNoteService implements TaskSe
private void notifyNewTask(Task task) {
if (personInformation.getId().equals(task.getResponsible().getId())
- && !personInformation.getId().equals(task.getAuthor().getId())) {
+ && !personInformation.getId().equals(task.getAuthor().getId())
+ && task.getResolved() != null && !task.getResolved()
+ ) {
notifyService.send(
TaskNewNotify.builder()
.authorName(task.getAuthor().getName())
diff --git a/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/parser/PipelineParser.java b/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/parser/PipelineParser.java
index b242911..10605d1 100644
--- a/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/parser/PipelineParser.java
+++ b/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/parser/PipelineParser.java
@@ -18,6 +18,7 @@ import org.springframework.core.convert.ConversionService;
import org.springframework.stereotype.Service;
import java.text.MessageFormat;
+import java.time.LocalDateTime;
import java.util.Collection;
import java.util.List;
import java.util.Set;
@@ -54,6 +55,8 @@ public class PipelineParser {
private final PersonProperty personProperty;
private final ConversionService conversionService;
+ private LocalDateTime lastUpdate = LocalDateTime.now();
+
public void scanNewPipeline() {
int page = 0;
Sheet projectSheet = projectService.getAll(PaginationImpl.of(page, COUNT));
@@ -72,7 +75,8 @@ public class PipelineParser {
private void processingProject(Project project) {
int page = 1;
- List pipelineJsons = getPipelineJsons(project.getId(), page);
+ LocalDateTime newLastUpdate = LocalDateTime.now();
+ List pipelineJsons = getPipelineJsons(project.getId(), page, lastUpdate);
while (!pipelineJsons.isEmpty()) {
@@ -104,15 +108,17 @@ public class PipelineParser {
}
- pipelineJsons = getPipelineJsons(project.getId(), ++page);
+ pipelineJsons = getPipelineJsons(project.getId(), ++page, lastUpdate);
}
+ lastUpdate = newLastUpdate;
}
- private List getPipelineJsons(Long projectId, int page) {
+ private List getPipelineJsons(Long projectId, int page, LocalDateTime afterUpdate) {
return HttpParse.request(MessageFormat.format(gitlabProperty.getUrlPipelines(), projectId, page))
.header(ACCEPT)
.header(HttpParse.AUTHORIZATION, HttpParse.BEARER + personProperty.getToken())
+ .getParameter("updated_after", afterUpdate.minusHours(12L).toString())
.executeList(PipelineJson.class);
}
diff --git a/bot-data/src/main/java/org/sadtech/bot/gitlab/data/impl/PipelineRepositoryImpl.java b/bot-data/src/main/java/org/sadtech/bot/gitlab/data/impl/PipelineRepositoryImpl.java
index 396ea3c..bea3db2 100644
--- a/bot-data/src/main/java/org/sadtech/bot/gitlab/data/impl/PipelineRepositoryImpl.java
+++ b/bot-data/src/main/java/org/sadtech/bot/gitlab/data/impl/PipelineRepositoryImpl.java
@@ -7,7 +7,7 @@ import org.sadtech.bot.gitlab.context.repository.PipelineRepository;
import org.sadtech.bot.gitlab.data.jpa.PipelineJpaRepository;
import org.sadtech.haiti.context.page.Pagination;
import org.sadtech.haiti.context.page.Sheet;
-import org.sadtech.haiti.database.repository.manager.AbstractSimpleManagerRepository;
+import org.sadtech.haiti.database.repository.manager.FilterManagerRepository;
import org.sadtech.haiti.database.util.Converter;
import org.springframework.stereotype.Repository;
@@ -19,7 +19,7 @@ import java.util.Set;
* @author upagge 17.01.2021
*/
@Repository
-public class PipelineRepositoryImpl extends AbstractSimpleManagerRepository implements PipelineRepository {
+public class PipelineRepositoryImpl extends FilterManagerRepository implements PipelineRepository {
private final PipelineJpaRepository jpaRepository;
diff --git a/bot-data/src/main/java/org/sadtech/bot/gitlab/data/jpa/PipelineJpaRepository.java b/bot-data/src/main/java/org/sadtech/bot/gitlab/data/jpa/PipelineJpaRepository.java
index 5b29c6f..dd91d98 100644
--- a/bot-data/src/main/java/org/sadtech/bot/gitlab/data/jpa/PipelineJpaRepository.java
+++ b/bot-data/src/main/java/org/sadtech/bot/gitlab/data/jpa/PipelineJpaRepository.java
@@ -4,7 +4,7 @@ import org.sadtech.bot.gitlab.context.domain.PipelineStatus;
import org.sadtech.bot.gitlab.context.domain.entity.Pipeline;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
-import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.support.JpaRepositoryImplementation;
import java.util.Set;
@@ -13,7 +13,7 @@ import java.util.Set;
*
* @author upagge 17.01.2021
*/
-public interface PipelineJpaRepository extends JpaRepository {
+public interface PipelineJpaRepository extends JpaRepositoryImplementation {
Page findAllByStatusIn(Set statuses, Pageable pageable);
diff --git a/pom.xml b/pom.xml
index 30cea5f..05b5551 100644
--- a/pom.xml
+++ b/pom.xml
@@ -86,7 +86,7 @@
0.0.2-SNAPSHOT
0.0.3-SNAPSHOT
- 0.0.2-RELEASE
+ 0.0.3-SNAPSHOT
0.0.2-SNAPSHOT
0.0.1-RELEASE