From 4ca568caf45e05129e521799fe72306deeee16f7 Mon Sep 17 00:00:00 2001 From: uPagge Date: Mon, 19 Apr 2021 19:50:29 +0300 Subject: [PATCH] =?UTF-8?q?=D1=80=D0=B0=D0=B7=D1=80=D0=B0=D0=B1=D0=BE?= =?UTF-8?q?=D1=82=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/messages_ru.properties | 4 ++-- .../notify/pullrequest/ConflictPrNotify.java | 8 ++++++-- .../domain/notify/task/TaskCloseNotify.java | 11 +++++++++-- .../context/service/MergeRequestsService.java | 2 +- .../context/service/PipelineService.java | 2 +- .../convert/MergeRequestJsonConverter.java | 4 +++- .../service/impl/DiscussionServiceImpl.java | 19 +++++++++++++++---- .../impl/MergeRequestsServiceImpl.java | 14 ++++++++++---- 8 files changed, 47 insertions(+), 17 deletions(-) diff --git a/bot-app/src/main/resources/messages_ru.properties b/bot-app/src/main/resources/messages_ru.properties index 1f67911..d232e0a 100644 --- a/bot-app/src/main/resources/messages_ru.properties +++ b/bot-app/src/main/resources/messages_ru.properties @@ -19,11 +19,11 @@ ui.answer.no_task=Задачи не найдены ui.answer.no_mr=Вы не назначены ответственным за MR notify.pr.new={0} *Новый MergeRequest | {1}*{2}[{3}]({4}){5}{2}{9}: {10} {12} {11}\n{7}: {8} notify.pr.forgotten={0} *Напоминание о просмотре PullRequest | {4}*{3}[{1}]({2}) -notify.pr.conflict={0} *Внимание! Конфликт в MergeRequest | {4}*{1}[{2}]({3}) +notify.pr.conflict={0} *Внимание! Конфликт в MergeRequest | {4}*{1}[{2}]({3}){1}Ветка: {5} notify.pr.smart={0} *Напоминание о MergeRequest | {6}*{3}[{1}]({2}){3}{4} изменил свое решение на {5} notify.pr.state={0} *Изменился статус MergeRequest | {7}*{1}[{2}]({3}){1}{4} {5} {6} notify.pr.update={0} *Обновление MergeRequest | {6}*{3}[{1}]({2}){3}Все задачи: {8}/{7}\nВаши задачи: {10}/{9}{3}{4}: {5} -notify.task.close={0} *Закрыта* [задача]({1}){2}*{3}*: {4} +notify.task.close={0} *Закрыта* [задача]({1}){2}*{3}*: {4}{2}Ваши задачи: {5}/{6} notify.task.new={0} *Назначена новая* [задача]({1}){2}*{3}*: {4} notify.project.new={0} *Новый Проект*{1}[{2}]({3}){1}{4}{5}: {6} notify.comment.bell={0} *Новое упоминание* | [MR]({1}){2}*{3}*: {4} diff --git a/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/notify/pullrequest/ConflictPrNotify.java b/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/notify/pullrequest/ConflictPrNotify.java index 9233925..c87b53c 100644 --- a/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/notify/pullrequest/ConflictPrNotify.java +++ b/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/notify/pullrequest/ConflictPrNotify.java @@ -8,20 +8,24 @@ import org.sadtech.bot.gitlab.context.utils.Smile; @Getter public class ConflictPrNotify extends PrNotify { + private final String sourceBranch; + @Builder private ConflictPrNotify( String name, String url, - String projectKey + String projectKey, + String sourceBranch ) { super(projectKey, name, url); + this.sourceBranch = sourceBranch; } @Override public String generateMessage(AppSettingService settingService) { return settingService.getMessage( "notify.pr.conflict", - Smile.DANGEROUS.getValue(), Smile.HR.getValue(), title, url, projectName + Smile.DANGEROUS.getValue(), Smile.HR.getValue(), title, url, projectName, sourceBranch ); } diff --git a/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/notify/task/TaskCloseNotify.java b/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/notify/task/TaskCloseNotify.java index cedd95f..20e5e62 100644 --- a/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/notify/task/TaskCloseNotify.java +++ b/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/notify/task/TaskCloseNotify.java @@ -11,20 +11,27 @@ import org.sadtech.bot.gitlab.context.utils.Smile; */ public class TaskCloseNotify extends TaskNotify { + private final Long personTasks; + private final Long personResolvedTasks; + @Builder protected TaskCloseNotify( String authorName, String url, - String messageTask + String messageTask, + Long personTasks, + Long personResolvedTasks ) { super(authorName, url, messageTask); + this.personTasks = personTasks; + this.personResolvedTasks = personResolvedTasks; } @Override public String generateMessage(AppSettingService settingService) { return settingService.getMessage( "notify.task.close", - Smile.TASK.getValue(), url, Smile.HR.getValue(), authorName, escapeMarkdown(messageTask) + Smile.TASK.getValue(), url, Smile.HR.getValue(), authorName, escapeMarkdown(messageTask), personTasks, personResolvedTasks ); } 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 a3380f0..f75c983 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 @@ -5,7 +5,7 @@ import org.sadtech.bot.gitlab.context.domain.MergeRequestState; import org.sadtech.bot.gitlab.context.domain.entity.MergeRequest; import org.sadtech.bot.gitlab.context.domain.filter.MergeRequestFilter; import org.sadtech.haiti.context.service.SimpleManagerService; -import org.sadtech.haiti.filter.FilterService; +import org.sadtech.haiti.context.service.simple.FilterService; import java.util.Set; 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 47e0988..88080e2 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 @@ -7,7 +7,7 @@ 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 org.sadtech.haiti.context.service.simple.FilterService; import java.util.Set; diff --git a/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/convert/MergeRequestJsonConverter.java b/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/convert/MergeRequestJsonConverter.java index cc76ccd..0f22d3b 100644 --- a/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/convert/MergeRequestJsonConverter.java +++ b/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/convert/MergeRequestJsonConverter.java @@ -34,7 +34,9 @@ public class MergeRequestJsonConverter implements Converter discussions = getAllByMergeRequestId(mergeRequest.getId()) + .stream() + .filter(discussion -> Objects.nonNull(discussion.getResponsible())) + .collect(Collectors.toList()); + final long allYouTasks = discussions.stream() + .filter(discussion -> personInformation.getId().equals(discussion.getFirstNote().getAuthor().getId())) + .count(); + final long resolvedYouTask = discussions.stream() + .filter(discussion -> personInformation.getId().equals(discussion.getFirstNote().getAuthor().getId()) && discussion.getResolved()) + .count(); notifyService.send( TaskCloseNotify.builder() .authorName(oldNote.getAuthor().getName()) .messageTask(oldNote.getBody()) .url(oldNote.getWebUrl()) + .personTasks(allYouTasks) + .personResolvedTasks(resolvedYouTask) .build() ); } @@ -182,9 +195,7 @@ public class DiscussionServiceImpl extends AbstractSimpleManagerService new NotFoundException("МержРеквест не найден")); @@ -112,7 +116,7 @@ public class MergeRequestsServiceImpl extends AbstractSimpleManagerService new NotFoundException("Проект не найден")); @@ -131,6 +135,7 @@ public class MergeRequestsServiceImpl extends AbstractSimpleManagerService discussions = discussionService.getAllByMergeRequestId(oldMergeRequest.getId()) .stream() @@ -169,6 +174,7 @@ public class MergeRequestsServiceImpl extends AbstractSimpleManagerService