diff --git a/bot-app/src/main/java/org/sadtech/bot/gitlab/app/scheduler/SchedulerService.java b/bot-app/src/main/java/org/sadtech/bot/gitlab/app/scheduler/SchedulerService.java
index 8585921..8c10320 100644
--- a/bot-app/src/main/java/org/sadtech/bot/gitlab/app/scheduler/SchedulerService.java
+++ b/bot-app/src/main/java/org/sadtech/bot/gitlab/app/scheduler/SchedulerService.java
@@ -36,6 +36,7 @@ public class SchedulerService {
@Scheduled(cron = "*/30 * * * * *")
public void newDiscussion() {
+ discussionParser.scanOldDiscussions();
discussionParser.scanNewDiscussion();
}
diff --git a/bot-app/src/main/resources/application.yaml b/bot-app/src/main/resources/application.yaml
index 744944f..f65c6a5 100644
--- a/bot-app/src/main/resources/application.yaml
+++ b/bot-app/src/main/resources/application.yaml
@@ -41,4 +41,5 @@ gitlab-bot:
url-pipeline: "${GITLAB_URL}/api/v4/projects/{0,number,#}/pipelines/{1,number,#}"
url-commit: "${GITLAB_URL}/api/v4/projects/{0,number,#}/merge_requests/{1,number,#}/commits?&page=1&per_page=1"
url-new-note: "${GITLAB_URL}/api/v4/projects/{0,number,#}/merge_requests/{1,number,#}/discussions/{2}/notes?body={3}"
- url-discussion: "${GITLAB_URL}/api/v4/projects/{0,number,#}/merge_requests/{1,number,#}/discussions?&page={2,number,integer}&per_page=100"
\ No newline at end of file
+ url-discussion: "${GITLAB_URL}/api/v4/projects/{0,number,#}/merge_requests/{1,number,#}/discussions?&page={2,number,integer}&per_page=100"
+ url-one-discussion: "${GITLAB_URL}/api/v4/projects/{0,number,#}/merge_requests/{1,number,#}/discussions/{2}"
\ No newline at end of file
diff --git a/bot-app/src/main/resources/liquibase/v.1.0.0/2021-01-14-create-tables.xml b/bot-app/src/main/resources/liquibase/v.1.0.0/2021-01-14-create-tables.xml
index 06d4f44..c718ad9 100644
--- a/bot-app/src/main/resources/liquibase/v.1.0.0/2021-01-14-create-tables.xml
+++ b/bot-app/src/main/resources/liquibase/v.1.0.0/2021-01-14-create-tables.xml
@@ -173,9 +173,6 @@
-
-
-
diff --git a/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/entity/Discussion.java b/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/entity/Discussion.java
index 5d3939a..08d899c 100644
--- a/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/entity/Discussion.java
+++ b/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/entity/Discussion.java
@@ -8,6 +8,7 @@ import org.sadtech.haiti.context.domain.BasicEntity;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
+import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
@@ -46,6 +47,7 @@ public class Discussion implements BasicEntity {
@OneToMany(
mappedBy = "discussion",
+ fetch = FetchType.EAGER,
cascade = {
CascadeType.PERSIST,
CascadeType.MERGE
diff --git a/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/entity/Note.java b/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/entity/Note.java
index 31518a3..a1e4197 100644
--- a/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/entity/Note.java
+++ b/bot-context/src/main/java/org/sadtech/bot/gitlab/context/domain/entity/Note.java
@@ -55,6 +55,9 @@ public class Note implements BasicEntity {
@Column(name = "web_url")
private String webUrl;
+ @Column(name = "resolvable")
+ private boolean resolvable;
+
@Column(name = "resolved")
private Boolean resolved;
diff --git a/bot-core/src/main/java/org/sadtech/bot/gitlab/core/config/properties/GitlabProperty.java b/bot-core/src/main/java/org/sadtech/bot/gitlab/core/config/properties/GitlabProperty.java
index 7c97064..d967e2f 100644
--- a/bot-core/src/main/java/org/sadtech/bot/gitlab/core/config/properties/GitlabProperty.java
+++ b/bot-core/src/main/java/org/sadtech/bot/gitlab/core/config/properties/GitlabProperty.java
@@ -58,4 +58,6 @@ public class GitlabProperty {
private String urlDiscussion;
+ private String urlOneDiscussion;
+
}
diff --git a/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/convert/NoteJsonConvert.java b/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/convert/NoteJsonConvert.java
index 30f6240..e4b6178 100644
--- a/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/convert/NoteJsonConvert.java
+++ b/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/convert/NoteJsonConvert.java
@@ -31,6 +31,7 @@ public class NoteJsonConvert implements Converter {
note.setNoteableIid(source.getNoteableIid());
note.setSystem(source.isSystem());
note.setResolved(source.getResolved());
+ note.setResolvable(source.isResolvable());
if (source.getResolvedBy() != null) {
note.setResolvedBy(personConverter.convert(source.getResolvedBy()));
}
diff --git a/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/DiscussionServiceImpl.java b/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/DiscussionServiceImpl.java
index fdd72b7..67f81a6 100644
--- a/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/DiscussionServiceImpl.java
+++ b/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/impl/DiscussionServiceImpl.java
@@ -69,10 +69,13 @@ public class DiscussionServiceImpl extends AbstractSimpleManagerService noteMap = discussionRepository.findById(discussion.getId()).orElseThrow(() -> new NotFoundException("Дискуссия не найдена"))
+ final Discussion oldDiscussion = discussionRepository.findById(discussion.getId()).orElseThrow(() -> new NotFoundException("Дискуссия не найдена"));
+ final Map noteMap = oldDiscussion
.getNotes().stream()
.collect(Collectors.toMap(Note::getId, note -> note));
+ discussion.setMergeRequest(oldDiscussion.getMergeRequest());
+ discussion.setResponsible(oldDiscussion.getResponsible());
discussion.getNotes().forEach(note -> updateNote(note, noteMap));
return discussionRepository.save(discussion);
@@ -81,9 +84,9 @@ public class DiscussionServiceImpl extends AbstractSimpleManagerService noteMap) {
if (noteMap.containsKey(note.getId())) {
final Note oldNote = noteMap.get(note.getId());
- if (!oldNote.getUpdated().equals(note.getUpdated())) {
- note.setWebUrl(oldNote.getWebUrl());
- }
+ note.setWebUrl(oldNote.getWebUrl());
+ } else {
+ notificationPersonal(note);
}
}
diff --git a/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/parser/DiscussionParser.java b/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/parser/DiscussionParser.java
index 2d9d3ea..616513a 100644
--- a/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/parser/DiscussionParser.java
+++ b/bot-core/src/main/java/org/sadtech/bot/gitlab/core/service/parser/DiscussionParser.java
@@ -9,6 +9,7 @@ import org.sadtech.bot.gitlab.core.config.properties.GitlabProperty;
import org.sadtech.bot.gitlab.core.config.properties.PersonProperty;
import org.sadtech.bot.gitlab.sdk.domain.DiscussionJson;
import org.sadtech.haiti.context.domain.ExistsContainer;
+import org.sadtech.haiti.context.exception.ConvertException;
import org.sadtech.haiti.context.page.Sheet;
import org.sadtech.haiti.core.page.PaginationImpl;
import org.sadtech.haiti.utils.network.HttpParse;
@@ -104,4 +105,27 @@ public class DiscussionParser {
.executeList(DiscussionJson.class);
}
+ public void scanOldDiscussions() {
+ int page = 0;
+ Sheet discussionSheet = discussionService.getAll(PaginationImpl.of(page, 100));
+
+ while (discussionSheet.hasContent()) {
+ final List discussions = discussionSheet.getContent();
+
+ for (Discussion discussion : discussions) {
+ final Discussion newDiscussion = HttpParse.request(MessageFormat.format(gitlabProperty.getUrlOneDiscussion(), discussion.getMergeRequest().getProjectId(), discussion.getMergeRequest().getTwoId(), discussion.getId()))
+ .header(ACCEPT)
+ .header(AUTHORIZATION, BEARER + personProperty.getToken())
+ .execute(DiscussionJson.class)
+ .map(json -> conversionService.convert(json, Discussion.class))
+ .orElseThrow(() -> new ConvertException("Ошибка парсинга дискуссии"));
+ discussionService.update(newDiscussion);
+ }
+
+ discussionSheet = discussionService.getAll(PaginationImpl.of(++page, 100));
+ }
+
+
+ }
+
}
diff --git a/gitlab-sdk/src/main/java/org/sadtech/bot/gitlab/sdk/domain/NoteJson.java b/gitlab-sdk/src/main/java/org/sadtech/bot/gitlab/sdk/domain/NoteJson.java
index 16d3ebc..0a8f3ec 100644
--- a/gitlab-sdk/src/main/java/org/sadtech/bot/gitlab/sdk/domain/NoteJson.java
+++ b/gitlab-sdk/src/main/java/org/sadtech/bot/gitlab/sdk/domain/NoteJson.java
@@ -35,7 +35,7 @@ public class NoteJson {
@JsonProperty("noteable_type")
private String noteableType;
- private Boolean resolvable;
+ private boolean resolvable;
private Boolean resolved;
diff --git a/telegram-bot/src/main/java/org/sadtech/bot/gitlab/telegram/unit/UnitConfig.java b/telegram-bot/src/main/java/org/sadtech/bot/gitlab/telegram/unit/UnitConfig.java
index 4c7d014..8a38070 100644
--- a/telegram-bot/src/main/java/org/sadtech/bot/gitlab/telegram/unit/UnitConfig.java
+++ b/telegram-bot/src/main/java/org/sadtech/bot/gitlab/telegram/unit/UnitConfig.java
@@ -95,7 +95,7 @@ public class UnitConfig {
final String discussionId = note.getDiscussion().getId();
discussionService.answer(discussionId, MessageFormat.format("@{0}, {1}", note.getAuthor().getUserName(), message.getText()));
}
- return BoxAnswer.of("Победа");
+ return BoxAnswer.of("");
}
}
return BoxAnswer.of("Ошибка");