diff --git a/bot-core/src/main/java/dev/struchkov/bot/gitlab/core/service/parser/PipelineParser.java b/bot-core/src/main/java/dev/struchkov/bot/gitlab/core/service/parser/PipelineParser.java index a3141df..f5a0cd9 100644 --- a/bot-core/src/main/java/dev/struchkov/bot/gitlab/core/service/parser/PipelineParser.java +++ b/bot-core/src/main/java/dev/struchkov/bot/gitlab/core/service/parser/PipelineParser.java @@ -34,6 +34,7 @@ import static dev.struchkov.bot.gitlab.context.domain.PipelineStatus.PENDING; import static dev.struchkov.bot.gitlab.context.domain.PipelineStatus.PREPARING; import static dev.struchkov.bot.gitlab.context.domain.PipelineStatus.RUNNING; import static dev.struchkov.bot.gitlab.context.domain.PipelineStatus.WAITING_FOR_RESOURCE; +import static dev.struchkov.haiti.utils.Checker.checkFalse; import static dev.struchkov.haiti.utils.Checker.checkNotEmpty; import static dev.struchkov.haiti.utils.concurrent.ForkJoinUtils.pullTaskResult; import static dev.struchkov.haiti.utils.concurrent.ForkJoinUtils.pullTaskResults; @@ -84,23 +85,14 @@ public class PipelineParser { final Map pipelineProjectMap = getPipelineShortJsons(projectIds).stream() .collect(Collectors.toMap(PipelineShortJson::getId, PipelineShortJson::getProjectId)); - if (!pipelineProjectMap.isEmpty()) { + if (checkNotEmpty(pipelineProjectMap)) { final ExistContainer existContainer = pipelineService.existsById(pipelineProjectMap.keySet()); - if (!existContainer.isAllFound()) { + if (checkFalse(existContainer.isAllFound())) { final Set idsNotFound = existContainer.getIdNoFound(); - final List> tasks = idsNotFound.stream() - .map(pipelineId -> new GetPipelineTask( - gitlabProperty.getUrlPipeline(), - pipelineProjectMap.get(pipelineId), - pipelineId, - personProperty.getToken() - )) - .map(forkJoinPool::submit) - .collect(Collectors.toList()); + final List pipelineJsons = getNewPipelineJson(pipelineProjectMap, idsNotFound); - final List pipelineJsons = pullTaskResult(tasks); if (checkNotEmpty(pipelineJsons)) { final List newPipelines = pipelineJsons.stream() .map(json -> conversionService.convert(json, Pipeline.class)) @@ -114,6 +106,21 @@ public class PipelineParser { log.debug("Конец обработки новых пайплайнов"); } + private List getNewPipelineJson(Map pipelineProjectMap, Set idsNotFound) { + final List> tasks = idsNotFound.stream() + .map(pipelineId -> new GetPipelineTask( + gitlabProperty.getUrlPipeline(), + pipelineProjectMap.get(pipelineId), + pipelineId, + personProperty.getToken() + )) + .map(forkJoinPool::submit) + .collect(Collectors.toList()); + + final List pipelineJsons = pullTaskResult(tasks); + return pipelineJsons; + } + private List getPipelineShortJsons(Set projectIds) { LocalDateTime newLastUpdate = LocalDateTime.now(); final List>> tasks = projectIds.stream()