This commit is contained in:
Struchkov Mark 2024-02-06 09:39:33 +03:00
parent 8f48af4767
commit 39f364c22b
No known key found for this signature in database
GPG Key ID: A3F0AC3F0FA52F3C
7 changed files with 67 additions and 8 deletions

View File

@ -208,7 +208,8 @@ public class MergeRequestsServiceImpl implements MergeRequestsService {
private void notifyAssignee(AssigneeChanged assigneeChanged, MergeRequest oldMergeRequest, MergeRequest mergeRequest, Project project) { private void notifyAssignee(AssigneeChanged assigneeChanged, MergeRequest oldMergeRequest, MergeRequest mergeRequest, Project project) {
switch (assigneeChanged) { 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]: Добавить уведомление, если происходит удаление ревьювера //TODO [05.12.2022|uPagge]: Добавить уведомление, если происходит удаление ревьювера

View File

@ -120,10 +120,10 @@ public class PipelineParser {
} }
private List<PipelineShortJson> getPipelineShortJsons(Set<Long> projectIds) { private List<PipelineShortJson> getPipelineShortJsons(Set<Long> projectIds) {
LocalDateTime newLastUpdate = LocalDateTime.now(); final LocalDateTime newLastUpdate = LocalDateTime.now();
final List<ForkJoinTask<List<PipelineShortJson>>> tasks = projectIds.stream() final List<ForkJoinTask<List<PipelineShortJson>>> tasks = projectIds.stream()
.map(projectId -> new GetPipelineShortTask( .map(projectId -> new GetPipelineShortTask(
gitlabProperty.getPipelinesUrl(), gitlabProperty.getPipelineUrl(),
projectId, projectId,
lastUpdate, lastUpdate,
personProperty.getToken() personProperty.getToken()

View File

@ -3,6 +3,7 @@ package dev.struchkov.bot.gitlab.core.utils;
import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import dev.struchkov.haiti.utils.Inspector; import dev.struchkov.haiti.utils.Inspector;
import jakarta.validation.constraints.NotNull;
import okhttp3.HttpUrl; import okhttp3.HttpUrl;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;
import okhttp3.Request; import okhttp3.Request;
@ -15,6 +16,7 @@ import java.io.IOException;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.concurrent.TimeUnit;
import static dev.struchkov.haiti.utils.Checker.checkNotNull; import static dev.struchkov.haiti.utils.Checker.checkNotNull;
import static dev.struchkov.haiti.utils.Inspector.isNotNull; import static dev.struchkov.haiti.utils.Inspector.isNotNull;
@ -77,7 +79,7 @@ public class HttpParse {
final HttpUrl url = httpUrlBuilder.build(); final HttpUrl url = httpUrlBuilder.build();
final Request request = requestBuilder.url(url).build(); final Request request = requestBuilder.url(url).build();
log.trace("Выполняется okhttp3 запрос | {}", url); log.trace("Выполняется okhttp3 запрос | {}", url);
final OkHttpClient httpClient = new OkHttpClient(); final OkHttpClient httpClient = getNewClient();
try (final Response execute = httpClient.newCall(request).execute()) { try (final Response execute = httpClient.newCall(request).execute()) {
log.trace("Запрос выполнен | {}", url); log.trace("Запрос выполнен | {}", url);
if (execute.isSuccessful() && checkNotNull(execute.body())) { if (execute.isSuccessful() && checkNotNull(execute.body())) {
@ -95,10 +97,10 @@ public class HttpParse {
isNotNull(classOfT); isNotNull(classOfT);
final HttpUrl url = httpUrlBuilder.build(); final HttpUrl url = httpUrlBuilder.build();
final Request request = requestBuilder.url(url).build(); final Request request = requestBuilder.url(url).build();
log.trace("Выполняется okhttp3 запрос | {}", url); log.debug("Выполняется okhttp3 запрос | {}", url);
final OkHttpClient httpClient = new OkHttpClient(); final OkHttpClient httpClient = getNewClient();
try (Response execute = httpClient.newCall(request).execute()) { try (Response execute = httpClient.newCall(request).execute()) {
log.trace("Запрос выполнен | {}", url); log.debug("Запрос выполнен | {}", url);
ResponseBody body = execute.body(); ResponseBody body = execute.body();
if (execute.isSuccessful() && checkNotNull(body)) { if (execute.isSuccessful() && checkNotNull(body)) {
final String stringBody = body.string(); final String stringBody = body.string();
@ -111,4 +113,13 @@ public class HttpParse {
return Collections.emptyList(); 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();
}
} }

View File

@ -4,5 +4,6 @@
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.17.xsd"> xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.17.xsd">
<include file="v.1.0.0/changelog.xml" relativeToChangelogFile="true"/> <include file="v.1.0.0/changelog.xml" relativeToChangelogFile="true"/>
<include file="v.2.0.0/changelog.xml" relativeToChangelogFile="true"/>
</databaseChangeLog> </databaseChangeLog>

View File

@ -0,0 +1,34 @@
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.17.xsd">
<changeSet id="2024-02-06-change-varchar" author="struchkov">
<modifyDataType tableName="merge_request" columnName="title" newDataType="varchar"/>
<modifyDataType tableName="merge_request" columnName="description" newDataType="varchar"/>
<modifyDataType tableName="merge_request" columnName="state" newDataType="varchar"/>
<modifyDataType tableName="merge_request" columnName="web_url" newDataType="varchar"/>
<modifyDataType tableName="merge_request" columnName="source_branch" newDataType="varchar"/>
<modifyDataType tableName="merge_request" columnName="target_branch" newDataType="varchar"/>
<modifyDataType tableName="discussion" columnName="id" newDataType="varchar"/>
<modifyDataType tableName="discussion_merge_request" columnName="discussion_id" newDataType="varchar"/>
<modifyDataType tableName="merge_request_label" columnName="label" newDataType="varchar"/>
<modifyDataType tableName="note" columnName="type" newDataType="varchar"/>
<modifyDataType tableName="note" columnName="body" newDataType="varchar"/>
<modifyDataType tableName="note" columnName="noteable_type" newDataType="varchar"/>
<modifyDataType tableName="note" columnName="resolvable" newDataType="varchar"/>
<modifyDataType tableName="note" columnName="web_url" newDataType="varchar"/>
<modifyDataType tableName="person" columnName="username" newDataType="varchar"/>
<modifyDataType tableName="person" columnName="name" newDataType="varchar"/>
<modifyDataType tableName="person" columnName="web_url" newDataType="varchar"/>
<modifyDataType tableName="pipeline" columnName="ref" newDataType="varchar"/>
<modifyDataType tableName="pipeline" columnName="status" newDataType="varchar"/>
<modifyDataType tableName="pipeline" columnName="web_url" newDataType="varchar"/>
<modifyDataType tableName="project" columnName="name" newDataType="varchar"/>
<modifyDataType tableName="project" columnName="description" newDataType="varchar"/>
<modifyDataType tableName="project" columnName="web_url" newDataType="varchar"/>
<modifyDataType tableName="project" columnName="ssh_url_to_repo" newDataType="varchar"/>
<modifyDataType tableName="project" columnName="http_url_to_repo" newDataType="varchar"/>
</changeSet>
</databaseChangeLog>

View File

@ -0,0 +1,12 @@
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.17.xsd">
<changeSet id="2024-02-06-add-tab-v-2-0-0" author="uPagge">
<tagDatabase tag="v.2.0.0"/>
</changeSet>
<include file="2024-02-06-change-varchar.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>

View File

@ -31,7 +31,7 @@ public class NewMrForReviewNotifyGenerator implements NotifyBoxAnswerGenerator<N
final StringBuilder builder = new StringBuilder(Icons.FUN).append(" *New merge request for review*") final StringBuilder builder = new StringBuilder(Icons.FUN).append(" *New merge request for review*")
.append(Icons.HR) .append(Icons.HR)
.append(notify.getTitle()); .append(escapeMarkdown(notify.getTitle()));
if (!labelText.isEmpty()) { if (!labelText.isEmpty()) {
builder.append("\n\n").append(labelText); builder.append("\n\n").append(labelText);