From bd014f1a994b0cec1718f4033ec9342db2e171c6 Mon Sep 17 00:00:00 2001 From: Struchkov Mark Date: Tue, 20 Dec 2022 14:41:46 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=B8=D0=BD=D0=B3.=20=D0=A3=D0=B4=D0=B0=D0=BB=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=BD=D0=B5=D0=B8=D1=81=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7?= =?UTF-8?q?=D1=83=D0=B5=D0=BC=D1=8B=D0=B5=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81?= =?UTF-8?q?=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/notify/GoodMorningNotify.java | 7 +-- .../gitlab/context/utils/MessageUtils.java | 12 +++--- .../telegram/service/unit/TaskProcessing.java | 43 ------------------- .../PullRequestNeedWorkProcessing.java | 32 -------------- .../PullRequestReviewProcessing.java | 36 ---------------- 5 files changed, 8 insertions(+), 122 deletions(-) delete mode 100644 telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/unit/TaskProcessing.java delete mode 100644 telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/unit/pullrequest/PullRequestNeedWorkProcessing.java delete mode 100644 telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/unit/pullrequest/PullRequestReviewProcessing.java diff --git a/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/domain/notify/GoodMorningNotify.java b/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/domain/notify/GoodMorningNotify.java index aad6c68..52cae90 100644 --- a/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/domain/notify/GoodMorningNotify.java +++ b/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/domain/notify/GoodMorningNotify.java @@ -1,7 +1,6 @@ package dev.struchkov.bot.gitlab.context.domain.notify; import dev.struchkov.bot.gitlab.context.domain.entity.MergeRequest; -import dev.struchkov.bot.gitlab.context.service.AppSettingService; import dev.struchkov.bot.gitlab.context.utils.MessageUtils; import dev.struchkov.bot.gitlab.context.utils.Smile; import lombok.Builder; @@ -20,8 +19,6 @@ public record GoodMorningNotify( String personName, String version ) implements Notify { - private static final Integer PR_COUNT = 4; - @Builder public GoodMorningNotify { } @@ -31,7 +28,7 @@ public record GoodMorningNotify( final StringBuilder message = new StringBuilder().append(Smile.SUN).append(" *Доброе утро, ").append(personName).append("* ").append(Smile.SUN).append(Smile.TWO_BR); if (!mergeRequestsReviews.isEmpty()) { message.append("Необходимо проверить ").append(mergeRequestsReviews.size()).append(" ПР:").append(Smile.BR); - MessageUtils.pullRequestForReview( + MessageUtils.mergeRequestForReview( mergeRequestsReviews.stream() .limit(3) .toList() @@ -39,7 +36,7 @@ public record GoodMorningNotify( } else { message.append("Поздравляю, у тебя ни одного ПР на проверку!"); } - MessageUtils.pullRequestForNeedWork( + MessageUtils.mergeRequestForNeedWork( mergeRequestsNeedWork.stream() .limit(3) .toList() diff --git a/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/utils/MessageUtils.java b/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/utils/MessageUtils.java index dcbf24e..eb8f536 100644 --- a/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/utils/MessageUtils.java +++ b/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/utils/MessageUtils.java @@ -17,33 +17,33 @@ import java.util.stream.Collectors; @NoArgsConstructor(access = AccessLevel.PRIVATE) public final class MessageUtils { - public static Optional pullRequestForReview(@NonNull List mergeRequestsReviews) { + public static Optional mergeRequestForReview(@NonNull List mergeRequestsReviews) { if (!mergeRequestsReviews.isEmpty()) { return Optional.of( mergeRequestsReviews.stream() - .map(MessageUtils::generateStringItemPullRequestReview) + .map(MessageUtils::generateStringItemMergeRequestReview) .collect(Collectors.joining("\n")) ); } return Optional.empty(); } - public static Optional pullRequestForNeedWork(@NonNull List mergeRequestNeedWork) { + public static Optional mergeRequestForNeedWork(@NonNull List mergeRequestNeedWork) { if (!mergeRequestNeedWork.isEmpty()) { return Optional.of( mergeRequestNeedWork.stream() - .map(MessageUtils::generateStringItemPullRequestNeedWork) + .map(MessageUtils::generateStringItemMergeRequestNeedWork) .collect(Collectors.joining("\n")) ); } return Optional.empty(); } - private static String generateStringItemPullRequestNeedWork(MergeRequest mergeRequest) { + private static String generateStringItemMergeRequestNeedWork(MergeRequest mergeRequest) { return "-- " + link(mergeRequest.getTitle(), mergeRequest.getWebUrl()); } - private static String generateStringItemPullRequestReview(MergeRequest mergeRequest) { + private static String generateStringItemMergeRequestReview(MergeRequest mergeRequest) { return Smile.statusPr(mergeRequest.getUpdatedDate()) + " " + link(mergeRequest.getTitle(), mergeRequest.getWebUrl()); } diff --git a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/unit/TaskProcessing.java b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/unit/TaskProcessing.java deleted file mode 100644 index 5429e88..0000000 --- a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/unit/TaskProcessing.java +++ /dev/null @@ -1,43 +0,0 @@ -//package dev.struchkov.bot.gitlab.telegram.service.unit; -// -///** -// * // TODO: 17.09.2020 Добавить описание. -// * -// * @author upagge 17.09.2020 -// */ -//@Component -//@RequiredArgsConstructor -//public class TaskProcessing implements ProcessingData { -// -// private final TaskService taskService; -// -// @Override -// public BoxAnswer processing(Message message) { -// final Person person = personService.getByTelegramId(message.getPersonId()) -// .orElseThrow(() -> new NotFoundException("Ошибочка")); -// final List tasks = taskService.getAllByResponsibleAndStatus(person.getLogin(), TaskStatus.OPEN); -// String messageText; -// if (tasks.isEmpty()) { -// messageText = "Задач нет"; -// } else { -// final String tasksString = tasks.stream() -// .map(this::createTaskString) -// .collect(Collectors.joining("\n")); -// messageText = MessageFormat.format( -// "Список ваших задач:\n\n{0}", -// tasksString -// ); -// } -// return BoxAnswer.of(messageText); -// return null; -// } -// -// private String createTaskString(Task task) { -// return MessageFormat.format( -// "- [{0}]({1})", -// task.getDescription(), task.getUrl() -// ); -// return null; -// } -// -//} diff --git a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/unit/pullrequest/PullRequestNeedWorkProcessing.java b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/unit/pullrequest/PullRequestNeedWorkProcessing.java deleted file mode 100644 index c7625f1..0000000 --- a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/unit/pullrequest/PullRequestNeedWorkProcessing.java +++ /dev/null @@ -1,32 +0,0 @@ -package dev.struchkov.bot.gitlab.telegram.service.unit.pullrequest; - -import dev.struchkov.bot.gitlab.context.service.MergeRequestsService; -import dev.struchkov.godfather.main.domain.BoxAnswer; -import dev.struchkov.godfather.main.domain.content.Message; -import dev.struchkov.godfather.simple.core.unit.func.ProcessingData; -import lombok.RequiredArgsConstructor; - -import java.util.Optional; - -/** - * @author upagge 17.09.2020 - */ -//@Component -@RequiredArgsConstructor -public class PullRequestNeedWorkProcessing implements ProcessingData { - - private final MergeRequestsService mergeRequestsService; - - @Override - public Optional processing(Message message) { -// final Person person = personService.getByTelegramId(message.getPersonId()) -// .orElseThrow(() -> new NotFoundException("Пользователь не найден")); -// final List pullRequests = pullRequestsService.getAllByAuthorAndReviewerStatus(person.getLogin(), ReviewerStatus.UNAPPROVED); -// return BoxAnswer.of( -// MessageUtils.pullRequestForNeedWork(pullRequests) -// .orElse("Не найдено ПРов, которые нуждаются в доработке :)") -// ); - return Optional.empty(); - } - -} diff --git a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/unit/pullrequest/PullRequestReviewProcessing.java b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/unit/pullrequest/PullRequestReviewProcessing.java deleted file mode 100644 index 0c4c33d..0000000 --- a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/unit/pullrequest/PullRequestReviewProcessing.java +++ /dev/null @@ -1,36 +0,0 @@ -package dev.struchkov.bot.gitlab.telegram.service.unit.pullrequest; - -import dev.struchkov.bot.gitlab.context.service.MergeRequestsService; -import dev.struchkov.godfather.main.domain.BoxAnswer; -import dev.struchkov.godfather.main.domain.content.Message; -import dev.struchkov.godfather.simple.core.unit.func.ProcessingData; -import lombok.RequiredArgsConstructor; - -import java.util.Optional; - -/** - * @author upagge 17.09.2020 - */ -//@Component -@RequiredArgsConstructor -public class PullRequestReviewProcessing implements ProcessingData { - - private final MergeRequestsService mergeRequestsService; - - @Override - public Optional processing(Message message) { -// final Person person = personService.getByTelegramId(message.getPersonId()) -// .orElseThrow(() -> new NotFoundException("Пользователь не найден")); -// final List pullRequests = pullRequestsService.getAllByReviewerAndStatuses( -// person.getLogin(), -// ReviewerStatus.NEEDS_WORK, -// Collections.singleton(PullRequestStatus.OPEN) -// ); -// return BoxAnswer.of( -// MessageUtils.pullRequestForReview(pullRequests) -// .orElse("Все ПР проверены :)") -// ); - return Optional.empty(); - } - -}