From 39f364c22b41a0b483761e6bd14e75d9e8665c88 Mon Sep 17 00:00:00 2001 From: Struchkov Mark Date: Tue, 6 Feb 2024 09:39:33 +0300 Subject: [PATCH] fixes --- .../impl/MergeRequestsServiceImpl.java | 3 +- .../core/service/parser/PipelineParser.java | 4 +-- .../bot/gitlab/core/utils/HttpParse.java | 19 ++++++++--- .../main/resources/liquibase/changelog.xml | 1 + .../v.2.0.0/2024-02-06-change-varchar.xml | 34 +++++++++++++++++++ .../resources/liquibase/v.2.0.0/changelog.xml | 12 +++++++ .../notify/NewMrForReviewNotifyGenerator.java | 2 +- 7 files changed, 67 insertions(+), 8 deletions(-) create mode 100644 gitlab-app/src/main/resources/liquibase/v.2.0.0/2024-02-06-change-varchar.xml create mode 100644 gitlab-app/src/main/resources/liquibase/v.2.0.0/changelog.xml diff --git a/bot-core/src/main/java/dev/struchkov/bot/gitlab/core/service/impl/MergeRequestsServiceImpl.java b/bot-core/src/main/java/dev/struchkov/bot/gitlab/core/service/impl/MergeRequestsServiceImpl.java index 1bedbdf..683dadd 100644 --- a/bot-core/src/main/java/dev/struchkov/bot/gitlab/core/service/impl/MergeRequestsServiceImpl.java +++ b/bot-core/src/main/java/dev/struchkov/bot/gitlab/core/service/impl/MergeRequestsServiceImpl.java @@ -208,7 +208,8 @@ public class MergeRequestsServiceImpl implements MergeRequestsService { private void notifyAssignee(AssigneeChanged assigneeChanged, MergeRequest oldMergeRequest, MergeRequest mergeRequest, Project project) { switch (assigneeChanged) { - case BECOME -> sendNotifyNewAssignee(mergeRequest, project.getName(), getAssignee(oldMergeRequest).map(Person::getName).orElse(null)); + case BECOME -> + sendNotifyNewAssignee(mergeRequest, project.getName(), getAssignee(oldMergeRequest).map(Person::getName).orElse(null)); } } //TODO [05.12.2022|uPagge]: Добавить уведомление, если происходит удаление ревьювера 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 41f9ee1..1d8bc4e 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 @@ -120,10 +120,10 @@ public class PipelineParser { } private List getPipelineShortJsons(Set projectIds) { - LocalDateTime newLastUpdate = LocalDateTime.now(); + final LocalDateTime newLastUpdate = LocalDateTime.now(); final List>> tasks = projectIds.stream() .map(projectId -> new GetPipelineShortTask( - gitlabProperty.getPipelinesUrl(), + gitlabProperty.getPipelineUrl(), projectId, lastUpdate, personProperty.getToken() diff --git a/bot-core/src/main/java/dev/struchkov/bot/gitlab/core/utils/HttpParse.java b/bot-core/src/main/java/dev/struchkov/bot/gitlab/core/utils/HttpParse.java index f3e8866..227c3e4 100644 --- a/bot-core/src/main/java/dev/struchkov/bot/gitlab/core/utils/HttpParse.java +++ b/bot-core/src/main/java/dev/struchkov/bot/gitlab/core/utils/HttpParse.java @@ -3,6 +3,7 @@ package dev.struchkov.bot.gitlab.core.utils; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import dev.struchkov.haiti.utils.Inspector; +import jakarta.validation.constraints.NotNull; import okhttp3.HttpUrl; import okhttp3.OkHttpClient; import okhttp3.Request; @@ -15,6 +16,7 @@ import java.io.IOException; import java.util.Collections; import java.util.List; import java.util.Optional; +import java.util.concurrent.TimeUnit; import static dev.struchkov.haiti.utils.Checker.checkNotNull; import static dev.struchkov.haiti.utils.Inspector.isNotNull; @@ -77,7 +79,7 @@ public class HttpParse { final HttpUrl url = httpUrlBuilder.build(); final Request request = requestBuilder.url(url).build(); log.trace("Выполняется okhttp3 запрос | {}", url); - final OkHttpClient httpClient = new OkHttpClient(); + final OkHttpClient httpClient = getNewClient(); try (final Response execute = httpClient.newCall(request).execute()) { log.trace("Запрос выполнен | {}", url); if (execute.isSuccessful() && checkNotNull(execute.body())) { @@ -95,10 +97,10 @@ public class HttpParse { isNotNull(classOfT); final HttpUrl url = httpUrlBuilder.build(); final Request request = requestBuilder.url(url).build(); - log.trace("Выполняется okhttp3 запрос | {}", url); - final OkHttpClient httpClient = new OkHttpClient(); + log.debug("Выполняется okhttp3 запрос | {}", url); + final OkHttpClient httpClient = getNewClient(); try (Response execute = httpClient.newCall(request).execute()) { - log.trace("Запрос выполнен | {}", url); + log.debug("Запрос выполнен | {}", url); ResponseBody body = execute.body(); if (execute.isSuccessful() && checkNotNull(body)) { final String stringBody = body.string(); @@ -111,4 +113,13 @@ public class HttpParse { return Collections.emptyList(); } + @NotNull + private static OkHttpClient getNewClient() { + return new OkHttpClient().newBuilder() + .connectTimeout(30, TimeUnit.SECONDS) + .readTimeout(30, TimeUnit.SECONDS) + .writeTimeout(30, TimeUnit.SECONDS) + .build(); + } + } \ No newline at end of file diff --git a/gitlab-app/src/main/resources/liquibase/changelog.xml b/gitlab-app/src/main/resources/liquibase/changelog.xml index 7035840..ced62ea 100644 --- a/gitlab-app/src/main/resources/liquibase/changelog.xml +++ b/gitlab-app/src/main/resources/liquibase/changelog.xml @@ -4,5 +4,6 @@ xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.17.xsd"> + \ No newline at end of file diff --git a/gitlab-app/src/main/resources/liquibase/v.2.0.0/2024-02-06-change-varchar.xml b/gitlab-app/src/main/resources/liquibase/v.2.0.0/2024-02-06-change-varchar.xml new file mode 100644 index 0000000..7c35c85 --- /dev/null +++ b/gitlab-app/src/main/resources/liquibase/v.2.0.0/2024-02-06-change-varchar.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/gitlab-app/src/main/resources/liquibase/v.2.0.0/changelog.xml b/gitlab-app/src/main/resources/liquibase/v.2.0.0/changelog.xml new file mode 100644 index 0000000..4ba8d94 --- /dev/null +++ b/gitlab-app/src/main/resources/liquibase/v.2.0.0/changelog.xml @@ -0,0 +1,12 @@ + + + + + + + + + \ No newline at end of file diff --git a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/notify/NewMrForReviewNotifyGenerator.java b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/notify/NewMrForReviewNotifyGenerator.java index 0ff33c6..41b8064 100644 --- a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/notify/NewMrForReviewNotifyGenerator.java +++ b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/notify/NewMrForReviewNotifyGenerator.java @@ -31,7 +31,7 @@ public class NewMrForReviewNotifyGenerator implements NotifyBoxAnswerGenerator