From 7a24bed95396758ca95ba735b0de4ecead7ca771 Mon Sep 17 00:00:00 2001 From: uPagge Date: Fri, 6 Nov 2020 11:25:11 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D1=80=D0=B0=D0=B1=D0=BE=D0=BA?= =?UTF-8?q?=D0=B8=20=D0=B4=D0=BB=D1=8F=20=D0=BB=D0=BE=D0=BA=D0=B0=D0=BB?= =?UTF-8?q?=D1=8C=D0=BD=D0=BE=D0=B3=D0=BE=20=D0=B1=D0=BE=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application-dev.yaml | 20 ++++---- .../src/main/resources/application-prod.yaml | 20 ++++---- .../main/resources/liquibase/change-log.xml | 1 + .../v.3.0.0/2020-10-31-add-new-columns-pr.xml | 20 ++++++++ .../liquibase/v.3.0.0/cumulative.xml | 8 +++ .../vcs/bitbucket/sdk/domain/Properties.java | 3 ++ bitbucketbot-context/pom.xml | 2 +- .../context/domain/entity/PullRequest.java | 9 ++++ bitbucketbot-core/pom.xml | 3 +- .../AbstractPullRequestBitbucketParser.java | 2 +- .../converter/PullRequestJsonConverter.java | 3 ++ .../service/impl/PullRequestsServiceImpl.java | 33 +++++++------ pom.xml | 49 +++++++++++++++++++ 13 files changed, 134 insertions(+), 39 deletions(-) create mode 100644 bitbucket-app/src/main/resources/liquibase/v.3.0.0/2020-10-31-add-new-columns-pr.xml create mode 100644 bitbucket-app/src/main/resources/liquibase/v.3.0.0/cumulative.xml diff --git a/bitbucket-app/src/main/resources/application-dev.yaml b/bitbucket-app/src/main/resources/application-dev.yaml index dc3cf69..a5b2fc3 100644 --- a/bitbucket-app/src/main/resources/application-dev.yaml +++ b/bitbucket-app/src/main/resources/application-dev.yaml @@ -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) \ No newline at end of file + project-url: ${TEAMCITY_URL}/app/rest/projects + build-url: ${TEAMCITY_URL}/app/rest/builds/?locator=project:(id:{0}),branch:(default:any) \ No newline at end of file diff --git a/bitbucket-app/src/main/resources/application-prod.yaml b/bitbucket-app/src/main/resources/application-prod.yaml index 13a5397..f9582d0 100644 --- a/bitbucket-app/src/main/resources/application-prod.yaml +++ b/bitbucket-app/src/main/resources/application-prod.yaml @@ -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) \ No newline at end of file + project-url: ${TEAMCITY_URL}/app/rest/projects + build-url: ${TEAMCITY_URL}/app/rest/builds/?locator=project:(id:{0}),branch:(default:any) \ No newline at end of file diff --git a/bitbucket-app/src/main/resources/liquibase/change-log.xml b/bitbucket-app/src/main/resources/liquibase/change-log.xml index 7b8a334..f06f7b5 100644 --- a/bitbucket-app/src/main/resources/liquibase/change-log.xml +++ b/bitbucket-app/src/main/resources/liquibase/change-log.xml @@ -4,5 +4,6 @@ xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd"> + \ No newline at end of file diff --git a/bitbucket-app/src/main/resources/liquibase/v.3.0.0/2020-10-31-add-new-columns-pr.xml b/bitbucket-app/src/main/resources/liquibase/v.3.0.0/2020-10-31-add-new-columns-pr.xml new file mode 100644 index 0000000..d879bfa --- /dev/null +++ b/bitbucket-app/src/main/resources/liquibase/v.3.0.0/2020-10-31-add-new-columns-pr.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/bitbucket-app/src/main/resources/liquibase/v.3.0.0/cumulative.xml b/bitbucket-app/src/main/resources/liquibase/v.3.0.0/cumulative.xml new file mode 100644 index 0000000..7a29266 --- /dev/null +++ b/bitbucket-app/src/main/resources/liquibase/v.3.0.0/cumulative.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/bitbucket-sdk/src/main/java/org/sadtech/bot/vcs/bitbucket/sdk/domain/Properties.java b/bitbucket-sdk/src/main/java/org/sadtech/bot/vcs/bitbucket/sdk/domain/Properties.java index 21e309e..fc6d251 100644 --- a/bitbucket-sdk/src/main/java/org/sadtech/bot/vcs/bitbucket/sdk/domain/Properties.java +++ b/bitbucket-sdk/src/main/java/org/sadtech/bot/vcs/bitbucket/sdk/domain/Properties.java @@ -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; } diff --git a/bitbucketbot-context/pom.xml b/bitbucketbot-context/pom.xml index 841bb70..46889e0 100644 --- a/bitbucketbot-context/pom.xml +++ b/bitbucketbot-context/pom.xml @@ -10,7 +10,7 @@ 4.0.0 bitbucketbot-context - 3.0.1-SNAPSHOT + ${org.sadtech.bot.bitbucket-context.version} diff --git a/bitbucketbot-context/src/main/java/org/sadtech/bot/vsc/bitbucketbot/context/domain/entity/PullRequest.java b/bitbucketbot-context/src/main/java/org/sadtech/bot/vsc/bitbucketbot/context/domain/entity/PullRequest.java index c155309..44bfa96 100644 --- a/bitbucketbot-context/src/main/java/org/sadtech/bot/vsc/bitbucketbot/context/domain/entity/PullRequest.java +++ b/bitbucketbot-context/src/main/java/org/sadtech/bot/vsc/bitbucketbot/context/domain/entity/PullRequest.java @@ -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; + /** * Ревьюверы */ diff --git a/bitbucketbot-core/pom.xml b/bitbucketbot-core/pom.xml index 07037e7..70c2546 100644 --- a/bitbucketbot-core/pom.xml +++ b/bitbucketbot-core/pom.xml @@ -10,13 +10,12 @@ 4.0.0 bitbucketbot-core - 3.1.0-SNAPSHOT + ${org.sadtech.bot.bitbucket-context.version} org.sadtech.bot.bitbucketbot bitbucketbot-context - 3.0.1-SNAPSHOT diff --git a/bitbucketbot-core/src/main/java/org/sadtech/bot/vcs/bitbucket/core/AbstractPullRequestBitbucketParser.java b/bitbucketbot-core/src/main/java/org/sadtech/bot/vcs/bitbucket/core/AbstractPullRequestBitbucketParser.java index e8ffb9b..f3ffed5 100644 --- a/bitbucketbot-core/src/main/java/org/sadtech/bot/vcs/bitbucket/core/AbstractPullRequestBitbucketParser.java +++ b/bitbucketbot-core/src/main/java/org/sadtech/bot/vcs/bitbucket/core/AbstractPullRequestBitbucketParser.java @@ -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); } } diff --git a/bitbucketbot-core/src/main/java/org/sadtech/bot/vcs/bitbucket/core/service/converter/PullRequestJsonConverter.java b/bitbucketbot-core/src/main/java/org/sadtech/bot/vcs/bitbucket/core/service/converter/PullRequestJsonConverter.java index 83d1085..ec3845b 100644 --- a/bitbucketbot-core/src/main/java/org/sadtech/bot/vcs/bitbucket/core/service/converter/PullRequestJsonConverter.java +++ b/bitbucketbot-core/src/main/java/org/sadtech/bot/vcs/bitbucket/core/service/converter/PullRequestJsonConverter.java @@ -41,6 +41,9 @@ public class PullRequestJsonConverter implements Converter implements PullRequestsService { - private final NotifyService notifyService; - private final PullRequestsRepository pullRequestsRepository; - private final RatingService ratingService; - private final FilterService filterService; + protected final NotifyService notifyService; + protected final PullRequestsRepository pullRequestsRepository; + protected final RatingService ratingService; + protected final FilterService filterService; - private final RatingProperty ratingProperty; + protected final RatingProperty ratingProperty; protected PullRequestsServiceImpl( PullRequestsRepository pullRequestsRepository, @@ -99,7 +99,7 @@ public class PullRequestsServiceImpl extends AbstractSimpleManagerService smartReviewers = pullRequest.getReviewers().stream() .filter( @@ -147,7 +150,7 @@ public class PullRequestsServiceImpl extends AbstractSimpleManagerService oldReviewers = oldPullRequest.getReviewers().stream() .collect(Collectors.toMap(Reviewer::getPersonLogin, reviewer -> reviewer)); final Map newReviewers = newPullRequest.getReviewers().stream() @@ -274,7 +277,7 @@ public class PullRequestsServiceImpl extends AbstractSimpleManagerService smartReviewers = oldPullRequest.getReviewers().stream() @@ -299,7 +302,7 @@ public class PullRequestsServiceImpl extends AbstractSimpleManagerService 1.8 + 1.8 + 1.8 3.0.0-RELEASE 3.0.0-RELEASE 3.0.0-RELEASE 3.0.0-RELEASE 3.0.0-RELEASE + 3.0.0-RELEASE 3.0.0-RELEASE 3.0.0-RELEASE @@ -74,6 +77,12 @@ ${org.sadtech.bot.teamcity-sdk.version} + + org.sadtech.bot.bitbucketbot + bitbucketbot-context + ${org.sadtech.bot.bitbucket-context.version} + + org.sadtech.bot.bitbucketbot bitbucket-sdk @@ -167,6 +176,46 @@ + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.0 + + 8 + 8 + + + + org.apache.maven.plugins + maven-source-plugin + 2.2.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.9.1 + + + attach-javadocs + + jar + + + + + + + uPagge