Добавление тасок

This commit is contained in:
upagge 2020-09-12 17:41:38 +03:00
parent d2cd4b62f5
commit 9289957723
No known key found for this signature in database
GPG Key ID: 15CD012E46F6BA34
18 changed files with 168 additions and 22 deletions

View File

@ -12,5 +12,6 @@ import org.springframework.stereotype.Component;
public class InitProperty { public class InitProperty {
private Long startCommentId; private Long startCommentId;
private boolean use = false;
} }

View File

@ -30,6 +30,9 @@ public class Comment {
@EqualsAndHashCode.Include @EqualsAndHashCode.Include
private Long id; private Long id;
@Column(name = "url_api")
private String urlApi;
@Column(name = "url") @Column(name = "url")
private String url; private String url;

View File

@ -0,0 +1,47 @@
package org.sadtech.bot.bitbucketbot.domain.entity;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* // TODO: 12.09.2020 Добавить описание.
*
* @author upagge 12.09.2020
*/
@Getter
@Setter
@Entity
@Table(name = "pull_request")
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
public class PullRequestMini {
/**
* Идентификатор
*/
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
@EqualsAndHashCode.Include
private Long id;
/**
* Адрес ПР
*/
@Column(name = "url")
private String url;
/**
* Автор ПР
*/
@Column(name = "author_login")
private String authorLogin;
}

View File

@ -5,7 +5,6 @@ import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.sadtech.bot.bitbucketbot.domain.TaskStatus; import org.sadtech.bot.bitbucketbot.domain.TaskStatus;
import javax.persistence.CascadeType;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.EnumType; import javax.persistence.EnumType;
@ -15,6 +14,7 @@ import javax.persistence.JoinTable;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.Table; import javax.persistence.Table;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List; import java.util.List;
@Entity @Entity
@ -63,8 +63,11 @@ public class Task {
@Column(name = "author_login") @Column(name = "author_login")
private String author; private String author;
@Column(name = "responsible_login")
private String responsible;
@JoinTable @JoinTable
@OneToMany(cascade = CascadeType.ALL) @OneToMany
private List<Comment> comments; private List<Comment> comments = new ArrayList<>();
} }

View File

@ -1,13 +1,16 @@
package org.sadtech.bot.bitbucketbot.repository; package org.sadtech.bot.bitbucketbot.repository;
import lombok.NonNull;
import org.sadtech.basic.context.repository.SimpleManagerRepository; import org.sadtech.basic.context.repository.SimpleManagerRepository;
import org.sadtech.basic.context.repository.simple.FilterOperation; import org.sadtech.basic.context.repository.simple.FilterOperation;
import org.sadtech.bot.bitbucketbot.domain.IdAndStatusPr; import org.sadtech.bot.bitbucketbot.domain.IdAndStatusPr;
import org.sadtech.bot.bitbucketbot.domain.PullRequestStatus; import org.sadtech.bot.bitbucketbot.domain.PullRequestStatus;
import org.sadtech.bot.bitbucketbot.domain.ReviewerStatus; import org.sadtech.bot.bitbucketbot.domain.ReviewerStatus;
import org.sadtech.bot.bitbucketbot.domain.entity.PullRequest; import org.sadtech.bot.bitbucketbot.domain.entity.PullRequest;
import org.sadtech.bot.bitbucketbot.domain.entity.PullRequestMini;
import java.util.List; import java.util.List;
import java.util.Optional;
import java.util.Set; import java.util.Set;
public interface PullRequestsRepository extends SimpleManagerRepository<PullRequest, Long>, FilterOperation<PullRequest> { public interface PullRequestsRepository extends SimpleManagerRepository<PullRequest, Long>, FilterOperation<PullRequest> {
@ -18,4 +21,6 @@ public interface PullRequestsRepository extends SimpleManagerRepository<PullRequ
Set<IdAndStatusPr> findAllIdByStatusIn(Set<PullRequestStatus> statuses); Set<IdAndStatusPr> findAllIdByStatusIn(Set<PullRequestStatus> statuses);
Optional<PullRequestMini> findMiniInfoById(@NonNull Long id);
} }

View File

@ -1,25 +1,31 @@
package org.sadtech.bot.bitbucketbot.repository.impl; package org.sadtech.bot.bitbucketbot.repository.impl;
import lombok.NonNull;
import org.sadtech.basic.database.repository.manager.FilterManagerRepository; import org.sadtech.basic.database.repository.manager.FilterManagerRepository;
import org.sadtech.bot.bitbucketbot.domain.IdAndStatusPr; import org.sadtech.bot.bitbucketbot.domain.IdAndStatusPr;
import org.sadtech.bot.bitbucketbot.domain.PullRequestStatus; import org.sadtech.bot.bitbucketbot.domain.PullRequestStatus;
import org.sadtech.bot.bitbucketbot.domain.ReviewerStatus; import org.sadtech.bot.bitbucketbot.domain.ReviewerStatus;
import org.sadtech.bot.bitbucketbot.domain.entity.PullRequest; import org.sadtech.bot.bitbucketbot.domain.entity.PullRequest;
import org.sadtech.bot.bitbucketbot.domain.entity.PullRequestMini;
import org.sadtech.bot.bitbucketbot.repository.PullRequestsRepository; import org.sadtech.bot.bitbucketbot.repository.PullRequestsRepository;
import org.sadtech.bot.bitbucketbot.repository.jpa.PullRequestMiniRepositoryJpa;
import org.sadtech.bot.bitbucketbot.repository.jpa.PullRequestsRepositoryJpa; import org.sadtech.bot.bitbucketbot.repository.jpa.PullRequestsRepositoryJpa;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
import java.util.Optional;
import java.util.Set; import java.util.Set;
@Repository @Repository
public class PullRequestsRepositoryImpl extends FilterManagerRepository<PullRequest, Long> implements PullRequestsRepository { public class PullRequestsRepositoryImpl extends FilterManagerRepository<PullRequest, Long> implements PullRequestsRepository {
private final PullRequestsRepositoryJpa repositoryJpa; private final PullRequestsRepositoryJpa repositoryJpa;
private final PullRequestMiniRepositoryJpa pullRequestMiniRepositoryJpa;
public PullRequestsRepositoryImpl(PullRequestsRepositoryJpa jpaRepository) { public PullRequestsRepositoryImpl(PullRequestsRepositoryJpa jpaRepository, PullRequestMiniRepositoryJpa pullRequestMiniRepositoryJpa) {
super(jpaRepository); super(jpaRepository);
repositoryJpa = jpaRepository; repositoryJpa = jpaRepository;
this.pullRequestMiniRepositoryJpa = pullRequestMiniRepositoryJpa;
} }
@Override @Override
@ -37,4 +43,9 @@ public class PullRequestsRepositoryImpl extends FilterManagerRepository<PullRequ
return repositoryJpa.findAllIdByStatusIn(statuses); return repositoryJpa.findAllIdByStatusIn(statuses);
} }
@Override
public Optional<PullRequestMini> findMiniInfoById(@NonNull Long id) {
return pullRequestMiniRepositoryJpa.findById(id);
}
} }

View File

@ -0,0 +1,12 @@
package org.sadtech.bot.bitbucketbot.repository.jpa;
import org.sadtech.bot.bitbucketbot.domain.entity.PullRequestMini;
import org.springframework.data.jpa.repository.JpaRepository;
/**
* // TODO: 12.09.2020 Добавить описание.
*
* @author upagge 12.09.2020
*/
public interface PullRequestMiniRepositoryJpa extends JpaRepository<PullRequestMini, Long> {
}

View File

@ -39,6 +39,9 @@ public interface PullRequestsRepositoryJpa extends JpaRepositoryImplementation<P
@Query("SELECT p.id from PullRequest p") @Query("SELECT p.id from PullRequest p")
Set<Long> findAllIds(); Set<Long> findAllIds();
@Query("SELECT p.authorLogin from PullRequest p WHERE p.id = :id")
Optional<String> findAuthorById(@Param("id") Long id);
// @Query("SELECT p FROM PullRequest p WHERE p.authorLogin = :login AND p.createDate BETWEEN :dateFrom AND :dateTo") // @Query("SELECT p FROM PullRequest p WHERE p.authorLogin = :login AND p.createDate BETWEEN :dateFrom AND :dateTo")
// List<PullRequest> findAllByAuthorAndDateBetween(@Param("login") String login, @Param("dateFrom") LocalDateTime dateFrom, @Param("dateTo") LocalDateTime dateTo); // List<PullRequest> findAllByAuthorAndDateBetween(@Param("login") String login, @Param("dateFrom") LocalDateTime dateFrom, @Param("dateTo") LocalDateTime dateTo);

View File

@ -7,9 +7,11 @@ import org.sadtech.bot.bitbucketbot.domain.IdAndStatusPr;
import org.sadtech.bot.bitbucketbot.domain.PullRequestStatus; import org.sadtech.bot.bitbucketbot.domain.PullRequestStatus;
import org.sadtech.bot.bitbucketbot.domain.ReviewerStatus; import org.sadtech.bot.bitbucketbot.domain.ReviewerStatus;
import org.sadtech.bot.bitbucketbot.domain.entity.PullRequest; import org.sadtech.bot.bitbucketbot.domain.entity.PullRequest;
import org.sadtech.bot.bitbucketbot.domain.entity.PullRequestMini;
import org.sadtech.bot.bitbucketbot.domain.filter.PullRequestFilter; import org.sadtech.bot.bitbucketbot.domain.filter.PullRequestFilter;
import java.util.List; import java.util.List;
import java.util.Optional;
import java.util.Set; import java.util.Set;
public interface PullRequestsService extends SimpleManagerService<PullRequest, Long>, FilterService<PullRequest, PullRequestFilter> { public interface PullRequestsService extends SimpleManagerService<PullRequest, Long>, FilterService<PullRequest, PullRequestFilter> {
@ -27,4 +29,6 @@ public interface PullRequestsService extends SimpleManagerService<PullRequest, L
*/ */
Set<IdAndStatusPr> getAllId(Set<PullRequestStatus> statuses); Set<IdAndStatusPr> getAllId(Set<PullRequestStatus> statuses);
Optional<PullRequestMini> getMiniInfo(@NonNull Long pullRequestId);
} }

View File

@ -21,7 +21,7 @@ public class ResultScanToComment implements Converter<ResultScan, Comment> {
comment.setAuthor(commentJson.getAuthor().getName()); comment.setAuthor(commentJson.getAuthor().getName());
comment.setPullRequestId(resultScan.getPullRequestId()); comment.setPullRequestId(resultScan.getPullRequestId());
comment.setMessage(commentJson.getText()); comment.setMessage(commentJson.getText());
comment.setUrl(resultScan.getUrlComment()); comment.setUrlApi(resultScan.getCommentApiUrl());
comment.setBitbucketVersion(commentJson.getVersion()); comment.setBitbucketVersion(commentJson.getVersion());
comment.setAnswers( comment.setAnswers(
commentJson.getComments().stream() commentJson.getComments().stream()

View File

@ -1,7 +1,10 @@
package org.sadtech.bot.bitbucketbot.service.converter; package org.sadtech.bot.bitbucketbot.service.converter;
import org.sadtech.basic.context.exception.ConvertException;
import org.sadtech.bot.bitbucketbot.domain.TaskStatus;
import org.sadtech.bot.bitbucketbot.domain.entity.Task; import org.sadtech.bot.bitbucketbot.domain.entity.Task;
import org.sadtech.bot.bitbucketbot.dto.bitbucket.CommentJson; import org.sadtech.bot.bitbucketbot.dto.bitbucket.CommentJson;
import org.sadtech.bot.bitbucketbot.dto.bitbucket.CommentState;
import org.sadtech.bot.bitbucketbot.service.executor.ResultScan; import org.sadtech.bot.bitbucketbot.service.executor.ResultScan;
import org.springframework.core.convert.converter.Converter; import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -19,7 +22,20 @@ public class ResultScanToTaskConvert implements Converter<ResultScan, Task> {
task.setCreateDate(json.getCreatedDate()); task.setCreateDate(json.getCreatedDate());
task.setBitbucketVersion(json.getVersion()); task.setBitbucketVersion(json.getVersion());
task.setPullRequestId(resultScan.getPullRequestId()); task.setPullRequestId(resultScan.getPullRequestId());
task.setStatus(convertState(json.getState()));
task.setUrlApi(resultScan.getCommentApiUrl());
return task; return task;
} }
private TaskStatus convertState(CommentState state) {
switch (state) {
case RESOLVED:
return TaskStatus.RESOLVED;
case OPEN:
return TaskStatus.OPEN;
default:
throw new ConvertException("Неподдерживаемый тип задачи");
}
}
} }

View File

@ -8,7 +8,7 @@ import org.sadtech.bot.bitbucketbot.dto.bitbucket.CommentJson;
@RequiredArgsConstructor @RequiredArgsConstructor
public class ResultScan { public class ResultScan {
private final String urlComment; private final String commentApiUrl;
private final Long pullRequestId; private final Long pullRequestId;
private final CommentJson commentJson; private final CommentJson commentJson;

View File

@ -2,7 +2,6 @@ package org.sadtech.bot.bitbucketbot.service.impl;
import lombok.NonNull; import lombok.NonNull;
import org.sadtech.basic.core.service.AbstractSimpleManagerService; import org.sadtech.basic.core.service.AbstractSimpleManagerService;
import org.sadtech.bot.bitbucketbot.config.InitProperty;
import org.sadtech.bot.bitbucketbot.domain.change.comment.CommentChange; import org.sadtech.bot.bitbucketbot.domain.change.comment.CommentChange;
import org.sadtech.bot.bitbucketbot.domain.entity.Comment; import org.sadtech.bot.bitbucketbot.domain.entity.Comment;
import org.sadtech.bot.bitbucketbot.exception.NotFoundException; import org.sadtech.bot.bitbucketbot.exception.NotFoundException;
@ -27,23 +26,17 @@ public class CommentServiceImpl extends AbstractSimpleManagerService<Comment, Lo
private final CommentRepository commentRepository; private final CommentRepository commentRepository;
private final PersonService personService; private final PersonService personService;
private final ChangeService changeService; private final ChangeService changeService;
private final InitProperty initProperty;
public CommentServiceImpl(CommentRepository commentRepository, PersonService personService, ChangeService changeService, InitProperty initProperty) { public CommentServiceImpl(CommentRepository commentRepository, PersonService personService, ChangeService changeService) {
super(commentRepository); super(commentRepository);
this.personService = personService; this.personService = personService;
this.commentRepository = commentRepository; this.commentRepository = commentRepository;
this.changeService = changeService; this.changeService = changeService;
this.initProperty = initProperty;
} }
@Override @Override
public Long getLastCommentId() { public Long getLastCommentId() {
return commentRepository.findFirstByOrderByIdDesc().map(Comment::getId).orElse(getInitCommentId()); return commentRepository.findFirstByOrderByIdDesc().map(Comment::getId).orElse(0L);
}
private Long getInitCommentId() {
return initProperty.getStartCommentId() != null ? initProperty.getStartCommentId() : 0L;
} }
@Override @Override
@ -53,6 +46,7 @@ public class CommentServiceImpl extends AbstractSimpleManagerService<Comment, Lo
@Override @Override
public Comment create(@NonNull Comment comment) { public Comment create(@NonNull Comment comment) {
comment.getAnswers().clear();
final Comment newComment = commentRepository.save(comment); final Comment newComment = commentRepository.save(comment);
notificationPersonal(comment); notificationPersonal(comment);
return newComment; return newComment;

View File

@ -16,6 +16,7 @@ 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.ReviewersPrChange;
import org.sadtech.bot.bitbucketbot.domain.change.pullrequest.UpdatePrChange; import org.sadtech.bot.bitbucketbot.domain.change.pullrequest.UpdatePrChange;
import org.sadtech.bot.bitbucketbot.domain.entity.PullRequest; import org.sadtech.bot.bitbucketbot.domain.entity.PullRequest;
import org.sadtech.bot.bitbucketbot.domain.entity.PullRequestMini;
import org.sadtech.bot.bitbucketbot.domain.entity.PullRequest_; import org.sadtech.bot.bitbucketbot.domain.entity.PullRequest_;
import org.sadtech.bot.bitbucketbot.domain.entity.Reviewer; import org.sadtech.bot.bitbucketbot.domain.entity.Reviewer;
import org.sadtech.bot.bitbucketbot.domain.filter.PullRequestFilter; import org.sadtech.bot.bitbucketbot.domain.filter.PullRequestFilter;
@ -182,6 +183,11 @@ public class PullRequestsServiceImpl extends AbstractSimpleManagerService<PullRe
return pullRequestsRepository.findAllIdByStatusIn(statuses); return pullRequestsRepository.findAllIdByStatusIn(statuses);
} }
@Override
public Optional<PullRequestMini> getMiniInfo(@NonNull Long pullRequestId) {
return pullRequestsRepository.findMiniInfoById(pullRequestId);
}
@Override @Override
public Sheet<PullRequest> getAll(@NonNull PullRequestFilter filter, Pagination pagination) { public Sheet<PullRequest> getAll(@NonNull PullRequestFilter filter, Pagination pagination) {
return filterService.getAll(filter, pagination); return filterService.getAll(filter, pagination);

View File

@ -36,6 +36,7 @@ public class TaskServiceImpl extends AbstractSimpleManagerService<Task, Long> im
@Override @Override
public Task create(@NonNull Task task) { public Task create(@NonNull Task task) {
Assert.isNotNull(task.getId(), "При создании объекта должен быть установлен идентификатор"); Assert.isNotNull(task.getId(), "При создании объекта должен быть установлен идентификатор");
task.getComments().clear();
final Task newTask = taskRepository.save(task); final Task newTask = taskRepository.save(task);
final PullRequest pullRequest = pullRequestsService.getById(task.getPullRequestId()) final PullRequest pullRequest = pullRequestsService.getById(task.getPullRequestId())

View File

@ -11,9 +11,11 @@ import org.sadtech.bot.bitbucketbot.domain.Answer;
import org.sadtech.bot.bitbucketbot.domain.change.comment.AnswerCommentChange; import org.sadtech.bot.bitbucketbot.domain.change.comment.AnswerCommentChange;
import org.sadtech.bot.bitbucketbot.domain.entity.Comment; import org.sadtech.bot.bitbucketbot.domain.entity.Comment;
import org.sadtech.bot.bitbucketbot.domain.entity.PullRequest; import org.sadtech.bot.bitbucketbot.domain.entity.PullRequest;
import org.sadtech.bot.bitbucketbot.domain.entity.PullRequestMini;
import org.sadtech.bot.bitbucketbot.domain.entity.Task; import org.sadtech.bot.bitbucketbot.domain.entity.Task;
import org.sadtech.bot.bitbucketbot.dto.bitbucket.CommentJson; import org.sadtech.bot.bitbucketbot.dto.bitbucket.CommentJson;
import org.sadtech.bot.bitbucketbot.dto.bitbucket.Severity; import org.sadtech.bot.bitbucketbot.dto.bitbucket.Severity;
import org.sadtech.bot.bitbucketbot.exception.NotFoundException;
import org.sadtech.bot.bitbucketbot.service.ChangeService; import org.sadtech.bot.bitbucketbot.service.ChangeService;
import org.sadtech.bot.bitbucketbot.service.CommentService; import org.sadtech.bot.bitbucketbot.service.CommentService;
import org.sadtech.bot.bitbucketbot.service.PersonService; import org.sadtech.bot.bitbucketbot.service.PersonService;
@ -26,6 +28,7 @@ import org.sadtech.bot.bitbucketbot.service.impl.ExecutorScanner;
import org.springframework.core.convert.ConversionService; import org.springframework.core.convert.ConversionService;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.text.MessageFormat;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -54,6 +57,8 @@ public class CommentAndTaskParser {
private final CommentSchedulerProperty commentSchedulerProperty; private final CommentSchedulerProperty commentSchedulerProperty;
private final InitProperty initProperty; private final InitProperty initProperty;
private boolean initStart = false;
public void scanNewCommentAndTask() { public void scanNewCommentAndTask() {
long commentId = getLastIdCommentOrTask() + 1; long commentId = getLastIdCommentOrTask() + 1;
int count = 0; int count = 0;
@ -62,8 +67,13 @@ public class CommentAndTaskParser {
executorScanner.registration(dataScans); executorScanner.registration(dataScans);
final List<ResultScan> resultScans = executorScanner.getResult(); final List<ResultScan> resultScans = executorScanner.getResult();
if (!resultScans.isEmpty()) { if (!resultScans.isEmpty()) {
commentService.createAll(getCommentsByResultScan(resultScans)); final long commentMax = commentService.createAll(getCommentsByResultScan(resultScans)).stream()
taskService.createAll(getTaskByResultScan(resultScans)); .mapToLong(Comment::getId)
.max().orElse(0L);
final long taskMax = taskService.createAll(getTaskByResultScan(resultScans)).stream()
.mapToLong(Task::getId)
.max().orElse(0L);
commentId = Long.max(commentMax, taskMax) + 1;
count = 0; count = 0;
} }
} while (count++ < commentSchedulerProperty.getNoCommentCount()); } while (count++ < commentSchedulerProperty.getNoCommentCount());
@ -71,8 +81,9 @@ public class CommentAndTaskParser {
private long getLastIdCommentOrTask() { private long getLastIdCommentOrTask() {
Long commentStartId = Long.max(commentService.getLastCommentId(), taskService.getLastTaskId()); Long commentStartId = Long.max(commentService.getLastCommentId(), taskService.getLastTaskId());
if (commentStartId == 0L && initProperty != null) { if (initProperty != null && !initStart && (commentStartId == 0L || initProperty.isUse())) {
commentStartId = initProperty.getStartCommentId(); commentStartId = initProperty.getStartCommentId();
initStart = true;
} }
return commentStartId; return commentStartId;
} }
@ -107,6 +118,13 @@ public class CommentAndTaskParser {
return resultScans.stream() return resultScans.stream()
.filter(resultScan -> Severity.NORMAL.equals(resultScan.getCommentJson().getSeverity())) .filter(resultScan -> Severity.NORMAL.equals(resultScan.getCommentJson().getSeverity()))
.map(resultScan -> conversionService.convert(resultScan, Comment.class)) .map(resultScan -> conversionService.convert(resultScan, Comment.class))
.peek(
comment -> {
final PullRequestMini pullRequestMini = pullRequestsService.getMiniInfo(comment.getPullRequestId())
.orElseThrow(() -> new NotFoundException("Автор ПР не найден"));
comment.setUrl(generateUrl(comment.getId(), pullRequestMini.getUrl()));
}
)
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
@ -114,9 +132,21 @@ public class CommentAndTaskParser {
return resultScans.stream() return resultScans.stream()
.filter(commentJson -> Severity.BLOCKER.equals(commentJson.getCommentJson().getSeverity())) .filter(commentJson -> Severity.BLOCKER.equals(commentJson.getCommentJson().getSeverity()))
.map(resultScan -> conversionService.convert(resultScan, Task.class)) .map(resultScan -> conversionService.convert(resultScan, Task.class))
.peek(
task -> {
final PullRequestMini pullRequestMini = pullRequestsService.getMiniInfo(task.getPullRequestId())
.orElseThrow(() -> new NotFoundException("Автор ПР не найден"));
task.setResponsible(pullRequestMini.getAuthorLogin());
task.setUrl(generateUrl(task.getId(), pullRequestMini.getUrl()));
}
)
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
private String generateUrl(@NonNull Long id, @NonNull String pullRequestUrl) {
return MessageFormat.format("{0}/overview?commentId={1}", pullRequestUrl, id).replaceAll(" ", "");
}
private String getCommentUrl(long commentId, PullRequest pullRequest) { private String getCommentUrl(long commentId, PullRequest pullRequest) {
return bitbucketProperty.getUrlPullRequestComment() return bitbucketProperty.getUrlPullRequestComment()
.replace("{projectKey}", pullRequest.getProjectKey()) .replace("{projectKey}", pullRequest.getProjectKey())

View File

@ -23,7 +23,8 @@ bitbucketbot:
no-comment-count: 20 no-comment-count: 20
comment-count: 100 comment-count: 100
init: init:
start-comment-id: 7623 start-comment-id: 7796
use: false
server-send: server-send:
url: http://188.225.35.149:8080/api/send url: http://188.225.35.149:8080/api/send
bitbucket: bitbucket:

View File

@ -91,7 +91,12 @@
<column name="id" type="int"> <column name="id" type="int">
<constraints primaryKey="true"/> <constraints primaryKey="true"/>
</column> </column>
<column name="url" type="varchar(300)"/> <column name="url" type="varchar(300)">
<constraints nullable="false" unique="true"/>
</column>
<column name="url_api" type="varchar(300)">
<constraints nullable="false" unique="true"/>
</column>
<column name="author_login" type="varchar(64)"> <column name="author_login" type="varchar(64)">
<constraints nullable="false" foreignKeyName="task_author_login_person_login" <constraints nullable="false" foreignKeyName="task_author_login_person_login"
references="person(login)" deleteCascade="true"/> references="person(login)" deleteCascade="true"/>
@ -139,15 +144,19 @@
<constraints nullable="false"/> <constraints nullable="false"/>
</column> </column>
<column name="url" type="varchar(300)"> <column name="url" type="varchar(300)">
<constraints nullable="false"/> <constraints nullable="false" unique="true"/>
</column> </column>
<column name="url_api" type="varchar(300)"> <column name="url_api" type="varchar(300)">
<constraints nullable="false"/> <constraints nullable="false" unique="true"/>
</column> </column>
<column name="author_login" type="varchar(64)"> <column name="author_login" type="varchar(64)">
<constraints nullable="false" foreignKeyName="task_author_login_person_login" <constraints nullable="false" foreignKeyName="task_author_login_person_login"
references="person(login)" deleteCascade="true"/> references="person(login)" deleteCascade="true"/>
</column> </column>
<column name="responsible_login" type="varchar(64)">
<constraints nullable="false" foreignKeyName="task_responsible_login_person_login"
references="person(login)" deleteCascade="true"/>
</column>
<column name="pull_request_id" type="int"> <column name="pull_request_id" type="int">
<constraints nullable="true" foreignKeyName="task_pull_request_id_pull_request_id" <constraints nullable="true" foreignKeyName="task_pull_request_id_pull_request_id"
references="pull_request(id)" deleteCascade="true"/> references="pull_request(id)" deleteCascade="true"/>