Рефакторинг. Удалил неиспользуемые классы

This commit is contained in:
Struchkov Mark 2022-12-20 14:41:46 +03:00
parent f4a425c8e4
commit bd014f1a99
Signed by: upagge
GPG Key ID: D3018BE7BA428CA6
5 changed files with 8 additions and 122 deletions

View File

@ -1,7 +1,6 @@
package dev.struchkov.bot.gitlab.context.domain.notify; package dev.struchkov.bot.gitlab.context.domain.notify;
import dev.struchkov.bot.gitlab.context.domain.entity.MergeRequest; 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.MessageUtils;
import dev.struchkov.bot.gitlab.context.utils.Smile; import dev.struchkov.bot.gitlab.context.utils.Smile;
import lombok.Builder; import lombok.Builder;
@ -20,8 +19,6 @@ public record GoodMorningNotify(
String personName, String version String personName, String version
) implements Notify { ) implements Notify {
private static final Integer PR_COUNT = 4;
@Builder @Builder
public GoodMorningNotify { 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); final StringBuilder message = new StringBuilder().append(Smile.SUN).append(" *Доброе утро, ").append(personName).append("* ").append(Smile.SUN).append(Smile.TWO_BR);
if (!mergeRequestsReviews.isEmpty()) { if (!mergeRequestsReviews.isEmpty()) {
message.append("Необходимо проверить ").append(mergeRequestsReviews.size()).append(" ПР:").append(Smile.BR); message.append("Необходимо проверить ").append(mergeRequestsReviews.size()).append(" ПР:").append(Smile.BR);
MessageUtils.pullRequestForReview( MessageUtils.mergeRequestForReview(
mergeRequestsReviews.stream() mergeRequestsReviews.stream()
.limit(3) .limit(3)
.toList() .toList()
@ -39,7 +36,7 @@ public record GoodMorningNotify(
} else { } else {
message.append("Поздравляю, у тебя ни одного ПР на проверку!"); message.append("Поздравляю, у тебя ни одного ПР на проверку!");
} }
MessageUtils.pullRequestForNeedWork( MessageUtils.mergeRequestForNeedWork(
mergeRequestsNeedWork.stream() mergeRequestsNeedWork.stream()
.limit(3) .limit(3)
.toList() .toList()

View File

@ -17,33 +17,33 @@ import java.util.stream.Collectors;
@NoArgsConstructor(access = AccessLevel.PRIVATE) @NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class MessageUtils { public final class MessageUtils {
public static Optional<String> pullRequestForReview(@NonNull List<MergeRequest> mergeRequestsReviews) { public static Optional<String> mergeRequestForReview(@NonNull List<MergeRequest> mergeRequestsReviews) {
if (!mergeRequestsReviews.isEmpty()) { if (!mergeRequestsReviews.isEmpty()) {
return Optional.of( return Optional.of(
mergeRequestsReviews.stream() mergeRequestsReviews.stream()
.map(MessageUtils::generateStringItemPullRequestReview) .map(MessageUtils::generateStringItemMergeRequestReview)
.collect(Collectors.joining("\n")) .collect(Collectors.joining("\n"))
); );
} }
return Optional.empty(); return Optional.empty();
} }
public static Optional<String> pullRequestForNeedWork(@NonNull List<MergeRequest> mergeRequestNeedWork) { public static Optional<String> mergeRequestForNeedWork(@NonNull List<MergeRequest> mergeRequestNeedWork) {
if (!mergeRequestNeedWork.isEmpty()) { if (!mergeRequestNeedWork.isEmpty()) {
return Optional.of( return Optional.of(
mergeRequestNeedWork.stream() mergeRequestNeedWork.stream()
.map(MessageUtils::generateStringItemPullRequestNeedWork) .map(MessageUtils::generateStringItemMergeRequestNeedWork)
.collect(Collectors.joining("\n")) .collect(Collectors.joining("\n"))
); );
} }
return Optional.empty(); return Optional.empty();
} }
private static String generateStringItemPullRequestNeedWork(MergeRequest mergeRequest) { private static String generateStringItemMergeRequestNeedWork(MergeRequest mergeRequest) {
return "-- " + link(mergeRequest.getTitle(), mergeRequest.getWebUrl()); return "-- " + link(mergeRequest.getTitle(), mergeRequest.getWebUrl());
} }
private static String generateStringItemPullRequestReview(MergeRequest mergeRequest) { private static String generateStringItemMergeRequestReview(MergeRequest mergeRequest) {
return Smile.statusPr(mergeRequest.getUpdatedDate()) + " " + return Smile.statusPr(mergeRequest.getUpdatedDate()) + " " +
link(mergeRequest.getTitle(), mergeRequest.getWebUrl()); link(mergeRequest.getTitle(), mergeRequest.getWebUrl());
} }

View File

@ -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<Message> {
//
// private final TaskService taskService;
//
// @Override
// public BoxAnswer processing(Message message) {
// final Person person = personService.getByTelegramId(message.getPersonId())
// .orElseThrow(() -> new NotFoundException("Ошибочка"));
// final List<Task> 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;
// }
//
//}

View File

@ -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<Message> {
private final MergeRequestsService mergeRequestsService;
@Override
public Optional<BoxAnswer> processing(Message message) {
// final Person person = personService.getByTelegramId(message.getPersonId())
// .orElseThrow(() -> new NotFoundException("Пользователь не найден"));
// final List<PullRequest> pullRequests = pullRequestsService.getAllByAuthorAndReviewerStatus(person.getLogin(), ReviewerStatus.UNAPPROVED);
// return BoxAnswer.of(
// MessageUtils.pullRequestForNeedWork(pullRequests)
// .orElse("Не найдено ПРов, которые нуждаются в доработке :)")
// );
return Optional.empty();
}
}

View File

@ -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<Message> {
private final MergeRequestsService mergeRequestsService;
@Override
public Optional<BoxAnswer> processing(Message message) {
// final Person person = personService.getByTelegramId(message.getPersonId())
// .orElseThrow(() -> new NotFoundException("Пользователь не найден"));
// final List<PullRequest> pullRequests = pullRequestsService.getAllByReviewerAndStatuses(
// person.getLogin(),
// ReviewerStatus.NEEDS_WORK,
// Collections.singleton(PullRequestStatus.OPEN)
// );
// return BoxAnswer.of(
// MessageUtils.pullRequestForReview(pullRequests)
// .orElse("Все ПР проверены :)")
// );
return Optional.empty();
}
}