Дорабоки для локального бота
This commit is contained in:
parent
3af712ffc0
commit
7a24bed953
@ -1,9 +1,9 @@
|
||||
spring:
|
||||
datasource:
|
||||
url: jdbc:postgresql://localhost:5432/bitbucket_bot
|
||||
username: postgres
|
||||
url: ${DATASOURCE_URL}
|
||||
username: ${DATASOURCE_USERNAME}
|
||||
driver-class-name: org.postgresql.Driver
|
||||
password: 121314Ma
|
||||
password: ${DATASOURCE_PASSWORD}
|
||||
liquibase:
|
||||
change-log: classpath:liquibase/change-log.xml
|
||||
jpa:
|
||||
@ -32,12 +32,12 @@ bitbucketbot:
|
||||
enable: true
|
||||
bitbucket:
|
||||
token: ${BITBUCKET_ADMIN_TOKEN}
|
||||
url-pull-request-open: http://192.168.236.164:7990/rest/api/1.0/dashboard/pull-requests?limit=150&state=OPEN
|
||||
url-pull-request-close: http://192.168.236.164:7990/rest/api/1.0/dashboard/pull-requests?limit=150&closedSince=86400
|
||||
url-pull-request-comment: http://192.168.236.164:7990/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/comments/{commentId}
|
||||
url-pull-request: http://192.168.236.164:7990/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/overview
|
||||
url-users: http://192.168.236.164:7990/rest/api/1.0/admin/users
|
||||
url-pull-request-open: ${BITBUCKET_URL}/rest/api/1.0/dashboard/pull-requests?limit=150&state=OPEN
|
||||
url-pull-request-close: ${BITBUCKET_URL}/rest/api/1.0/dashboard/pull-requests?limit=150&closedSince=86400
|
||||
url-pull-request-comment: ${BITBUCKET_URL}/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/comments/{commentId}
|
||||
url-pull-request: ${BITBUCKET_URL}/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/overview
|
||||
url-users: ${BITBUCKET_URL}/rest/api/1.0/admin/users
|
||||
teamcity:
|
||||
token: ${TEAMCITY_ADMIN_TOKEN}
|
||||
project-url: http://192.168.236.164:8111/app/rest/projects
|
||||
build-url: http://192.168.236.164:8111/app/rest/builds/?locator=project:(id:{0}),branch:(default:any)
|
||||
project-url: ${TEAMCITY_URL}/app/rest/projects
|
||||
build-url: ${TEAMCITY_URL}/app/rest/builds/?locator=project:(id:{0}),branch:(default:any)
|
@ -1,9 +1,9 @@
|
||||
spring:
|
||||
datasource:
|
||||
url: jdbc:postgresql://localhost:5432/bitbucket_bot
|
||||
username: postgres
|
||||
url: ${DATASOURCE_URL}
|
||||
username: ${DATASOURCE_USERNAME}
|
||||
driver-class-name: org.postgresql.Driver
|
||||
password:
|
||||
password: ${DATASOURCE_PASSWORD}
|
||||
liquibase:
|
||||
change-log: classpath:liquibase/change-log.xml
|
||||
jpa:
|
||||
@ -30,12 +30,12 @@ bitbucketbot:
|
||||
use: false
|
||||
bitbucket:
|
||||
token: ${BITBUCKET_ADMIN_TOKEN}
|
||||
url-pull-request-open: http://localhost:7990/rest/api/1.0/dashboard/pull-requests?limit=150&state=OPEN
|
||||
url-pull-request-close: http://localhost:7990/rest/api/1.0/dashboard/pull-requests?limit=150&closedSince=86400
|
||||
url-pull-request-comment: http://localhost:7990/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/comments/{commentId}
|
||||
url-pull-request: http://localhost:7990/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/overview
|
||||
url-users: http://localhost:7990/rest/api/1.0/admin/users
|
||||
url-pull-request-open: ${BITBUCKET_URL}/rest/api/1.0/dashboard/pull-requests?limit=150&state=OPEN
|
||||
url-pull-request-close: ${BITBUCKET_URL}/rest/api/1.0/dashboard/pull-requests?limit=150&closedSince=86400
|
||||
url-pull-request-comment: ${BITBUCKET_URL}/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/comments/{commentId}
|
||||
url-pull-request: ${BITBUCKET_URL}/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/overview
|
||||
url-users: ${BITBUCKET_URL}/rest/api/1.0/admin/users
|
||||
teamcity:
|
||||
token: ${TEAMCITY_ADMIN_TOKEN}
|
||||
project-url: http://localhost:8111/app/rest/projects
|
||||
build-url: http://localhost:8111/app/rest/builds/?locator=project:(id:{0}),branch:(default:any)
|
||||
project-url: ${TEAMCITY_URL}/app/rest/projects
|
||||
build-url: ${TEAMCITY_URL}/app/rest/builds/?locator=project:(id:{0}),branch:(default:any)
|
@ -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-cumulative.xml"/>
|
||||
<include file="liquibase/v.3.0.0/cumulative.xml"/>
|
||||
|
||||
</databaseChangeLog>
|
@ -0,0 +1,20 @@
|
||||
<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-10-31-add-columns-pull-request" author="upagge">
|
||||
<addColumn tableName="pull_request">
|
||||
<column name="resolved_task_count" type="integer">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="comment_count" type="integer">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="open_task_count" type="integer">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
</addColumn>
|
||||
</changeSet>
|
||||
|
||||
</databaseChangeLog>
|
@ -0,0 +1,8 @@
|
||||
<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">
|
||||
|
||||
<include file="liquibase/v.3.0.0/2020-10-31-add-new-columns-pr.xml"/>
|
||||
|
||||
</databaseChangeLog>
|
@ -6,5 +6,8 @@ import lombok.Data;
|
||||
public class Properties {
|
||||
|
||||
private MergeResult mergeResult;
|
||||
private Integer resolvedTaskCount = 0;
|
||||
private Integer commentCount = 0;
|
||||
private Integer openTaskCount = 0;
|
||||
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>bitbucketbot-context</artifactId>
|
||||
<version>3.0.1-SNAPSHOT</version>
|
||||
<version>${org.sadtech.bot.bitbucket-context.version}</version>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
@ -120,6 +120,15 @@ public class PullRequest {
|
||||
@Column(name = "author_login")
|
||||
private String authorLogin;
|
||||
|
||||
@Column(name = "resolved_task_count")
|
||||
private Integer resolvedTaskCount;
|
||||
|
||||
@Column(name = "comment_count")
|
||||
private Integer commentCount;
|
||||
|
||||
@Column(name = "open_task_count")
|
||||
private Integer openTaskCount;
|
||||
|
||||
/**
|
||||
* Ревьюверы
|
||||
*/
|
||||
|
@ -10,13 +10,12 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>bitbucketbot-core</artifactId>
|
||||
<version>3.1.0-SNAPSHOT</version>
|
||||
<version>${org.sadtech.bot.bitbucket-context.version}</version>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.sadtech.bot.bitbucketbot</groupId>
|
||||
<artifactId>bitbucketbot-context</artifactId>
|
||||
<version>3.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
@ -55,7 +55,7 @@ public abstract class AbstractPullRequestBitbucketParser implements PullRequestP
|
||||
log.info("Открыты: " + Arrays.toString(openId.toArray()));
|
||||
log.info("Закрыты: " + Arrays.toString(closeId.toArray()));
|
||||
log.info("Не найдены: " + Arrays.toString(newNotExistsId.toArray()));
|
||||
if (!newNotExistsId.isEmpty()) {
|
||||
if (!newNotExistsId.isEmpty() && !openId.isEmpty()) {
|
||||
pullRequestsService.deleteAllById(newNotExistsId);
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,9 @@ public class PullRequestJsonConverter implements Converter<PullRequestJson, Pull
|
||||
pullRequest.setReviewers(convertReviewers(json.getReviewers()));
|
||||
pullRequest.setBitbucketVersion(json.getVersion());
|
||||
pullRequest.setRepositoryId(json.getFromRef().getRepository().getId());
|
||||
pullRequest.setResolvedTaskCount(json.getProperties().getResolvedTaskCount());
|
||||
pullRequest.setCommentCount(json.getProperties().getCommentCount());
|
||||
pullRequest.setOpenTaskCount(json.getProperties().getOpenTaskCount());
|
||||
return pullRequest;
|
||||
}
|
||||
|
||||
|
@ -46,12 +46,12 @@ import java.util.stream.Collectors;
|
||||
@Service
|
||||
public class PullRequestsServiceImpl extends AbstractSimpleManagerService<PullRequest, Long> implements PullRequestsService {
|
||||
|
||||
private final NotifyService notifyService;
|
||||
private final PullRequestsRepository pullRequestsRepository;
|
||||
private final RatingService ratingService;
|
||||
private final FilterService<PullRequest, PullRequestFilter> filterService;
|
||||
protected final NotifyService notifyService;
|
||||
protected final PullRequestsRepository pullRequestsRepository;
|
||||
protected final RatingService ratingService;
|
||||
protected final FilterService<PullRequest, PullRequestFilter> filterService;
|
||||
|
||||
private final RatingProperty ratingProperty;
|
||||
protected final RatingProperty ratingProperty;
|
||||
|
||||
protected PullRequestsServiceImpl(
|
||||
PullRequestsRepository pullRequestsRepository,
|
||||
@ -99,7 +99,7 @@ public class PullRequestsServiceImpl extends AbstractSimpleManagerService<PullRe
|
||||
return newPullRequest;
|
||||
}
|
||||
|
||||
private void addRatingCreate(@NonNull String login) {
|
||||
protected void addRatingCreate(@NonNull String login) {
|
||||
if (ratingProperty.isEnabled()) {
|
||||
ratingService.addRating(login, PointType.CREATE_PULL_REQUEST, PointType.CREATE_PULL_REQUEST.getPoints());
|
||||
}
|
||||
@ -113,6 +113,9 @@ public class PullRequestsServiceImpl extends AbstractSimpleManagerService<PullRe
|
||||
|
||||
oldPullRequest.setTitle(pullRequest.getTitle());
|
||||
oldPullRequest.setDescription(pullRequest.getDescription());
|
||||
oldPullRequest.setOpenTaskCount(pullRequest.getResolvedTaskCount());
|
||||
oldPullRequest.setCommentCount(pullRequest.getOpenTaskCount());
|
||||
oldPullRequest.setResolvedTaskCount(pullRequest.getResolvedTaskCount());
|
||||
updateReviewers(oldPullRequest, pullRequest);
|
||||
oldPullRequest.setUpdateDate(pullRequest.getUpdateDate());
|
||||
updateBitbucketVersion(oldPullRequest, pullRequest);
|
||||
@ -122,7 +125,7 @@ public class PullRequestsServiceImpl extends AbstractSimpleManagerService<PullRe
|
||||
return pullRequestsRepository.save(oldPullRequest);
|
||||
}
|
||||
|
||||
private void forgottenNotification(PullRequest pullRequest) {
|
||||
protected void forgottenNotification(PullRequest pullRequest) {
|
||||
if (LocalDateTime.now().isAfter(pullRequest.getUpdateDate().plusHours(2L))) {
|
||||
final Set<String> smartReviewers = pullRequest.getReviewers().stream()
|
||||
.filter(
|
||||
@ -147,7 +150,7 @@ public class PullRequestsServiceImpl extends AbstractSimpleManagerService<PullRe
|
||||
}
|
||||
}
|
||||
|
||||
private void updateBitbucketVersion(PullRequest oldPullRequest, PullRequest pullRequest) {
|
||||
protected void updateBitbucketVersion(PullRequest oldPullRequest, PullRequest pullRequest) {
|
||||
if (
|
||||
!oldPullRequest.getBitbucketVersion().equals(pullRequest.getBitbucketVersion())
|
||||
) {
|
||||
@ -171,7 +174,7 @@ public class PullRequestsServiceImpl extends AbstractSimpleManagerService<PullRe
|
||||
}
|
||||
}
|
||||
|
||||
private void updateConflict(PullRequest oldPullRequest, PullRequest pullRequest) {
|
||||
protected void updateConflict(PullRequest oldPullRequest, PullRequest pullRequest) {
|
||||
if (!oldPullRequest.isConflict() && pullRequest.isConflict()) {
|
||||
notifyService.send(
|
||||
ConflictPrNotify.builder()
|
||||
@ -186,7 +189,7 @@ public class PullRequestsServiceImpl extends AbstractSimpleManagerService<PullRe
|
||||
oldPullRequest.setConflict(pullRequest.isConflict());
|
||||
}
|
||||
|
||||
private void updateStatus(PullRequest oldPullRequest, PullRequest newPullRequest) {
|
||||
protected void updateStatus(PullRequest oldPullRequest, PullRequest newPullRequest) {
|
||||
final PullRequestStatus oldStatus = oldPullRequest.getStatus();
|
||||
final PullRequestStatus newStatus = newPullRequest.getStatus();
|
||||
if (!oldStatus.equals(newStatus)) {
|
||||
@ -206,7 +209,7 @@ public class PullRequestsServiceImpl extends AbstractSimpleManagerService<PullRe
|
||||
}
|
||||
}
|
||||
|
||||
private void ratingStatus(PullRequest oldPullRequest, PullRequest newPullRequest) {
|
||||
protected void ratingStatus(PullRequest oldPullRequest, PullRequest newPullRequest) {
|
||||
if (ratingProperty.isEnabled()) {
|
||||
final String authorLogin = oldPullRequest.getAuthorLogin();
|
||||
switch (newPullRequest.getStatus()) {
|
||||
@ -223,7 +226,7 @@ public class PullRequestsServiceImpl extends AbstractSimpleManagerService<PullRe
|
||||
}
|
||||
}
|
||||
|
||||
private void updateReviewers(PullRequest oldPullRequest, PullRequest newPullRequest) {
|
||||
protected void updateReviewers(PullRequest oldPullRequest, PullRequest newPullRequest) {
|
||||
final Map<String, Reviewer> oldReviewers = oldPullRequest.getReviewers().stream()
|
||||
.collect(Collectors.toMap(Reviewer::getPersonLogin, reviewer -> reviewer));
|
||||
final Map<String, Reviewer> newReviewers = newPullRequest.getReviewers().stream()
|
||||
@ -274,7 +277,7 @@ public class PullRequestsServiceImpl extends AbstractSimpleManagerService<PullRe
|
||||
/**
|
||||
* Умное уведомление ревьюверов, после того, как кто-то изменил свое решение.
|
||||
*/
|
||||
private void smartNotifyAfterReviewerDecision(Reviewer newReviewer, PullRequest oldPullRequest) {
|
||||
protected void smartNotifyAfterReviewerDecision(Reviewer newReviewer, PullRequest oldPullRequest) {
|
||||
final ReviewerStatus newStatus = newReviewer.getStatus();
|
||||
if (!ReviewerStatus.NEEDS_WORK.equals(newStatus) && enoughTimHasPassedSinceUpdatePr(oldPullRequest.getUpdateDate())) {
|
||||
final List<Reviewer> smartReviewers = oldPullRequest.getReviewers().stream()
|
||||
@ -299,7 +302,7 @@ public class PullRequestsServiceImpl extends AbstractSimpleManagerService<PullRe
|
||||
}
|
||||
}
|
||||
|
||||
private boolean enoughTimHasPassedSinceUpdatePr(LocalDateTime updateDate) {
|
||||
protected boolean enoughTimHasPassedSinceUpdatePr(LocalDateTime updateDate) {
|
||||
return LocalDateTime.now().isAfter(updateDate.plusHours(4L));
|
||||
}
|
||||
|
||||
@ -344,7 +347,7 @@ public class PullRequestsServiceImpl extends AbstractSimpleManagerService<PullRe
|
||||
return filterService.exists(filter);
|
||||
}
|
||||
|
||||
private PullRequest findAndFillId(@NonNull PullRequest pullRequest) {
|
||||
protected PullRequest findAndFillId(@NonNull PullRequest pullRequest) {
|
||||
return pullRequestsRepository.findFirst(
|
||||
CriteriaFilter.create().and(
|
||||
CriteriaQuery.create()
|
||||
|
49
pom.xml
49
pom.xml
@ -27,12 +27,15 @@
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
|
||||
<org.sadtech.bot.bitbucket-app.version>3.0.0-RELEASE</org.sadtech.bot.bitbucket-app.version>
|
||||
<org.sadtech.bot-core.version>3.0.0-RELEASE</org.sadtech.bot-core.version>
|
||||
<org.sadtech.bot.teamcity-core.version>3.0.0-RELEASE</org.sadtech.bot.teamcity-core.version>
|
||||
<org.sadtech.bot.teamcity-sdk.version>3.0.0-RELEASE</org.sadtech.bot.teamcity-sdk.version>
|
||||
<org.sadtech.bot.bitbucket-sdk.version>3.0.0-RELEASE</org.sadtech.bot.bitbucket-sdk.version>
|
||||
<org.sadtech.bot.bitbucket-context.version>3.0.0-RELEASE</org.sadtech.bot.bitbucket-context.version>
|
||||
<org.sadtech.bot.rest.version>3.0.0-RELEASE</org.sadtech.bot.rest.version>
|
||||
<org.sadtech.bot.telegram.version>3.0.0-RELEASE</org.sadtech.bot.telegram.version>
|
||||
|
||||
@ -74,6 +77,12 @@
|
||||
<version>${org.sadtech.bot.teamcity-sdk.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.sadtech.bot.bitbucketbot</groupId>
|
||||
<artifactId>bitbucketbot-context</artifactId>
|
||||
<version>${org.sadtech.bot.bitbucket-context.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.sadtech.bot.bitbucketbot</groupId>
|
||||
<artifactId>bitbucket-sdk</artifactId>
|
||||
@ -167,6 +176,46 @@
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.0</version>
|
||||
<configuration>
|
||||
<source>8</source>
|
||||
<target>8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>2.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals>
|
||||
<goal>jar-no-fork</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.9.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<developers>
|
||||
<developer>
|
||||
<id>uPagge</id>
|
||||
|
Loading…
Reference in New Issue
Block a user