Исправление явных багов
This commit is contained in:
parent
456ede8f32
commit
42ab851117
@ -63,9 +63,9 @@ public class ReviewersPrChange extends PrChange {
|
||||
);
|
||||
}
|
||||
final String createMessage = stringBuilder.toString();
|
||||
return Smile.PEN + " *Изменения ревьюверов вашего ПР*" +
|
||||
return Smile.PEN + " *Изменения ревьюверов PullRequest*" +
|
||||
Smile.HR +
|
||||
"[" + title + "](" + url + ")\n" +
|
||||
"[" + title + "](" + url + ")" + Smile.HR +
|
||||
createMessage;
|
||||
}
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ public class CommentServiceImpl extends AbstractSimpleManagerService<Comment, Lo
|
||||
private void updateAnswer(Comment oldComment, Comment newComment) {
|
||||
final Set<Long> oldAnswerIds = oldComment.getAnswers();
|
||||
final Set<Long> newAnswerIds = newComment.getAnswers();
|
||||
if (!newAnswerIds.isEmpty()) {
|
||||
if (!oldAnswerIds.equals(newAnswerIds)) {
|
||||
final Set<Long> existsNewAnswersIds = commentRepository.existsById(newAnswerIds);
|
||||
final List<Comment> newAnswers = commentRepository.findAllById(existsNewAnswersIds).stream()
|
||||
.filter(comment -> !oldAnswerIds.contains(comment.getId()))
|
||||
|
@ -14,6 +14,7 @@ import org.sadtech.bot.bitbucketbot.domain.ReviewerStatus;
|
||||
import org.sadtech.bot.bitbucketbot.domain.change.pullrequest.ConflictPrChange;
|
||||
import org.sadtech.bot.bitbucketbot.domain.change.pullrequest.NewPrChange;
|
||||
import org.sadtech.bot.bitbucketbot.domain.change.pullrequest.ReviewersPrChange;
|
||||
import org.sadtech.bot.bitbucketbot.domain.change.pullrequest.StatusPrChange;
|
||||
import org.sadtech.bot.bitbucketbot.domain.change.pullrequest.UpdatePrChange;
|
||||
import org.sadtech.bot.bitbucketbot.domain.entity.PullRequest;
|
||||
import org.sadtech.bot.bitbucketbot.domain.entity.PullRequestMini;
|
||||
@ -104,8 +105,8 @@ public class PullRequestsServiceImpl extends AbstractSimpleManagerService<PullRe
|
||||
oldPullRequest.setConflict(pullRequest.isConflict());
|
||||
oldPullRequest.setTitle(pullRequest.getTitle());
|
||||
oldPullRequest.setDescription(pullRequest.getDescription());
|
||||
oldPullRequest.setStatus(pullRequest.getStatus());
|
||||
updateReviewers(oldPullRequest, pullRequest);
|
||||
updateStatus(oldPullRequest, pullRequest);
|
||||
|
||||
final PullRequest newPullRequest = pullRequestsRepository.save(oldPullRequest);
|
||||
if (!pullRequest.getBitbucketVersion().equals(newPullRequest.getBitbucketVersion())) {
|
||||
@ -122,6 +123,27 @@ public class PullRequestsServiceImpl extends AbstractSimpleManagerService<PullRe
|
||||
return newPullRequest;
|
||||
}
|
||||
|
||||
private void updateStatus(PullRequest oldPullRequest, PullRequest newPullRequest) {
|
||||
final PullRequestStatus oldStatus = oldPullRequest.getStatus();
|
||||
final PullRequestStatus newStatus = newPullRequest.getStatus();
|
||||
if (!oldStatus.equals(newStatus)) {
|
||||
changeService.save(
|
||||
StatusPrChange.builder()
|
||||
.name(newPullRequest.getTitle())
|
||||
.url(oldPullRequest.getUrl())
|
||||
.newStatus(newStatus)
|
||||
.oldStatus(oldStatus)
|
||||
.telegramIds(
|
||||
personService.getAllTelegramIdByLogin(
|
||||
Collections.singleton(oldPullRequest.getAuthorLogin())
|
||||
)
|
||||
)
|
||||
.build()
|
||||
);
|
||||
oldPullRequest.setStatus(newStatus);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateReviewers(PullRequest oldPullRequest, PullRequest newPullRequest) {
|
||||
final Map<String, Reviewer> oldReviewers = oldPullRequest.getReviewers().stream()
|
||||
.collect(Collectors.toMap(Reviewer::getPersonLogin, reviewer -> reviewer));
|
||||
|
@ -126,7 +126,7 @@ public class TaskServiceImpl extends AbstractSimpleManagerService<Task, Long> im
|
||||
private void updateAnswer(Task oldTask, Task task) {
|
||||
final Set<Long> oldAnswerIds = oldTask.getAnswers();
|
||||
final Set<Long> newAnswerIds = task.getAnswers();
|
||||
if (!newAnswerIds.isEmpty()) {
|
||||
if (!oldAnswerIds.equals(newAnswerIds)) {
|
||||
final Set<Long> existsNewAnswersIds = commentService.existsById(newAnswerIds);
|
||||
final List<Comment> newAnswers = commentService.getAllById(existsNewAnswersIds).stream()
|
||||
.filter(comment -> !oldAnswerIds.contains(comment.getId()))
|
||||
|
@ -174,7 +174,7 @@
|
||||
</createTable>
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="2020-09-08-create-table-" author="">
|
||||
<changeSet id="2020-09-08-create-table-task-comments" author="upagge">
|
||||
<createTable tableName="task_comments">
|
||||
<column name="task_id" type="integer">
|
||||
<constraints nullable="false" foreignKeyName="task_comments_task_id_task_id" references="task(id)"/>
|
||||
|
@ -4,5 +4,6 @@
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
|
||||
|
||||
<include file="liquibase/v.2.0.0/2020-09-06-create-table.xml"/>
|
||||
<include file="liquibase/v.2.0.0/2020-09-15-fix-task-comments.xml"/>
|
||||
|
||||
</databaseChangeLog>
|
@ -0,0 +1,24 @@
|
||||
<databaseChangeLog
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
|
||||
|
||||
<changeSet id="2020-09-15-drop-constraint-task-comments" author="upagge">
|
||||
<dropForeignKeyConstraint baseTableName="task_comments" constraintName="task_comments_comment_id_comment_id"/>
|
||||
<dropForeignKeyConstraint baseTableName="task_comments" constraintName="task_comments_task_id_task_id"/>
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="2020-09-15-create-constraint-task-comments" author="upagge">
|
||||
<addNotNullConstraint tableName="task_comments" columnName="comment_id"/>
|
||||
<addNotNullConstraint tableName="task_comments" columnName="task_id"/>
|
||||
<addForeignKeyConstraint baseTableName="task_comments" baseColumnNames="comment_id"
|
||||
constraintName="task_comments_comment_id_comment_id"
|
||||
referencedTableName="comment"
|
||||
referencedColumnNames="id" onDelete="CASCADE"/>
|
||||
<addForeignKeyConstraint baseTableName="task_comments" baseColumnNames="task_id"
|
||||
constraintName="task_comments_task_id_task_id"
|
||||
referencedTableName="task"
|
||||
referencedColumnNames="id" onDelete="CASCADE"/>
|
||||
</changeSet>
|
||||
|
||||
</databaseChangeLog>
|
Loading…
Reference in New Issue
Block a user