Что-то делал
This commit is contained in:
parent
2ad244de13
commit
6b8fd45937
2
pom.xml
2
pom.xml
@ -8,7 +8,7 @@
|
|||||||
<version>2.2.4.RELEASE</version>
|
<version>2.2.4.RELEASE</version>
|
||||||
<relativePath/> <!-- lookup parent from repository -->
|
<relativePath/> <!-- lookup parent from repository -->
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>com.tsc.bitbucketbot</groupId>
|
<groupId>org.sadtech.bot.bitbucketbot</groupId>
|
||||||
<artifactId>bitbucketbot</artifactId>
|
<artifactId>bitbucketbot</artifactId>
|
||||||
<version>2.0.0-SNAPSHOT</version>
|
<version>2.0.0-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
package com.tsc.bitbucketbot.dto.bitbucket.sheet;
|
|
||||||
|
|
||||||
import com.tsc.bitbucketbot.dto.bitbucket.PullRequestJson;
|
|
||||||
import com.tsc.bitbucketbot.dto.bitbucket.Sheet;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: Добавить описание класса.
|
|
||||||
*
|
|
||||||
* @author upagge [02.02.2020]
|
|
||||||
*/
|
|
||||||
public class PullRequestSheetJson extends Sheet<PullRequestJson> {
|
|
||||||
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
package com.tsc.bitbucketbot.dto.bitbucket.sheet;
|
|
||||||
|
|
||||||
import com.tsc.bitbucketbot.dto.bitbucket.Sheet;
|
|
||||||
import com.tsc.bitbucketbot.dto.bitbucket.UserJson;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: Добавить описание класса.
|
|
||||||
*
|
|
||||||
* @author upagge [02.02.2020]
|
|
||||||
*/
|
|
||||||
public class UserSheetJson extends Sheet<UserJson> {
|
|
||||||
|
|
||||||
}
|
|
@ -1,74 +0,0 @@
|
|||||||
package com.tsc.bitbucketbot.service;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import lombok.NonNull;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.net.URLConnection;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.zip.GZIPInputStream;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: Добавить описание класса.
|
|
||||||
*
|
|
||||||
* @author upagge [30.01.2020]
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
public class Utils {
|
|
||||||
|
|
||||||
private static ObjectMapper objectMapper;
|
|
||||||
|
|
||||||
static {
|
|
||||||
objectMapper = new ObjectMapper();
|
|
||||||
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Utils() {
|
|
||||||
throw new IllegalStateException("Утилитарный класс");
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
public static <T> Optional<T> urlToJson(String urlValue, String token, Class<T> classOfT) {
|
|
||||||
StringBuilder sb = null;
|
|
||||||
URLConnection urlCon;
|
|
||||||
try {
|
|
||||||
urlCon = new URL(urlValue).openConnection();
|
|
||||||
if (token != null) {
|
|
||||||
urlCon.setRequestProperty("Authorization", "Bearer " + token);
|
|
||||||
}
|
|
||||||
try (BufferedReader in = (isGzip(urlCon)) ?
|
|
||||||
new BufferedReader(new InputStreamReader(new GZIPInputStream(urlCon.getInputStream())))
|
|
||||||
: new BufferedReader(new InputStreamReader(urlCon.getInputStream()));) {
|
|
||||||
String inputLine;
|
|
||||||
sb = new StringBuilder();
|
|
||||||
while ((inputLine = in.readLine()) != null) {
|
|
||||||
sb.append(inputLine);
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.trace(e.getMessage());
|
|
||||||
}
|
|
||||||
if (sb != null) {
|
|
||||||
try {
|
|
||||||
return Optional.of(objectMapper.readValue(sb.toString(), classOfT));
|
|
||||||
} catch (JsonProcessingException e) {
|
|
||||||
log.error(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.error(e.getMessage());
|
|
||||||
}
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isGzip(URLConnection urlCon) {
|
|
||||||
return urlCon.getHeaderField("Content-Encoding") != null
|
|
||||||
&& urlCon.getHeaderField("Content-Encoding").equals("gzip");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
package com.tsc.bitbucketbot.service.executor;
|
|
||||||
|
|
||||||
import com.tsc.bitbucketbot.dto.bitbucket.CommentJson;
|
|
||||||
import com.tsc.bitbucketbot.service.Utils;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.concurrent.Callable;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class Seeker implements Callable<List<ResultScan>> {
|
|
||||||
|
|
||||||
private final List<DataScan> dataScan;
|
|
||||||
private final String token;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ResultScan> call() throws Exception {
|
|
||||||
return dataScan.stream()
|
|
||||||
.map(
|
|
||||||
data -> Utils.urlToJson(data.getUrlComment(), token, CommentJson.class)
|
|
||||||
.map(commentJson -> new ResultScan(data.getUrlComment(), data.getUrlPr(), commentJson))
|
|
||||||
)
|
|
||||||
.filter(Optional::isPresent)
|
|
||||||
.map(Optional::get)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot;
|
package org.sadtech.bot.bitbucketbot;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.config;
|
package org.sadtech.bot.bitbucketbot.config;
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
@ -22,7 +22,7 @@ public class AppConfig {
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public ExecutorService executorService() {
|
public ExecutorService executorService() {
|
||||||
return Executors.newFixedThreadPool(10);
|
return Executors.newFixedThreadPool(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.config;
|
package org.sadtech.bot.bitbucketbot.config;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.config;
|
package org.sadtech.bot.bitbucketbot.config;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.config;
|
package org.sadtech.bot.bitbucketbot.config;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
@ -1,9 +1,9 @@
|
|||||||
package com.tsc.bitbucketbot.controller;
|
package org.sadtech.bot.bitbucketbot.controller;
|
||||||
|
|
||||||
import com.tsc.bitbucketbot.domain.entity.User;
|
|
||||||
import com.tsc.bitbucketbot.dto.UserDto;
|
|
||||||
import com.tsc.bitbucketbot.service.UserService;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.entity.User;
|
||||||
|
import org.sadtech.bot.bitbucketbot.dto.UserDto;
|
||||||
|
import org.sadtech.bot.bitbucketbot.service.UserService;
|
||||||
import org.springframework.core.convert.ConversionService;
|
import org.springframework.core.convert.ConversionService;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.domain;
|
package org.sadtech.bot.bitbucketbot.domain;
|
||||||
|
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.domain;
|
package org.sadtech.bot.bitbucketbot.domain;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Добавить комментарий енума.
|
* TODO: Добавить комментарий енума.
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.domain;
|
package org.sadtech.bot.bitbucketbot.domain;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Добавить комментарий енума.
|
* TODO: Добавить комментарий енума.
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.domain;
|
package org.sadtech.bot.bitbucketbot.domain;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.domain;
|
package org.sadtech.bot.bitbucketbot.domain;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.domain;
|
package org.sadtech.bot.bitbucketbot.domain;
|
||||||
|
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.domain;
|
package org.sadtech.bot.bitbucketbot.domain;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author upagge [31.01.2020]
|
* @author upagge [31.01.2020]
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.domain;
|
package org.sadtech.bot.bitbucketbot.domain;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.domain;
|
package org.sadtech.bot.bitbucketbot.domain;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Добавить описание класса.
|
* TODO: Добавить описание класса.
|
@ -1,9 +1,9 @@
|
|||||||
package com.tsc.bitbucketbot.domain.change;
|
package org.sadtech.bot.bitbucketbot.domain.change;
|
||||||
|
|
||||||
import com.tsc.bitbucketbot.domain.Answer;
|
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.Answer;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.domain.change;
|
package org.sadtech.bot.bitbucketbot.domain.change;
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.domain.change;
|
package org.sadtech.bot.bitbucketbot.domain.change;
|
||||||
|
|
||||||
public enum ChangeType {
|
public enum ChangeType {
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.domain.change;
|
package org.sadtech.bot.bitbucketbot.domain.change;
|
||||||
|
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.domain.change;
|
package org.sadtech.bot.bitbucketbot.domain.change;
|
||||||
|
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.domain.change;
|
package org.sadtech.bot.bitbucketbot.domain.change;
|
||||||
|
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.domain.change;
|
package org.sadtech.bot.bitbucketbot.domain.change;
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
@ -1,9 +1,9 @@
|
|||||||
package com.tsc.bitbucketbot.domain.change;
|
package org.sadtech.bot.bitbucketbot.domain.change;
|
||||||
|
|
||||||
import com.tsc.bitbucketbot.domain.util.ReviewerChange;
|
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.util.ReviewerChange;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
@ -1,9 +1,9 @@
|
|||||||
package com.tsc.bitbucketbot.domain.change;
|
package org.sadtech.bot.bitbucketbot.domain.change;
|
||||||
|
|
||||||
import com.tsc.bitbucketbot.domain.PullRequestStatus;
|
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.PullRequestStatus;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.domain.change;
|
package org.sadtech.bot.bitbucketbot.domain.change;
|
||||||
|
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.domain.entity;
|
package org.sadtech.bot.bitbucketbot.domain.entity;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
@ -1,6 +1,5 @@
|
|||||||
package com.tsc.bitbucketbot.domain.entity;
|
package org.sadtech.bot.bitbucketbot.domain.entity;
|
||||||
|
|
||||||
import com.tsc.bitbucketbot.domain.PullRequestStatus;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
@ -8,6 +7,7 @@ import lombok.Getter;
|
|||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.PullRequestStatus;
|
||||||
|
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
@ -1,11 +1,11 @@
|
|||||||
package com.tsc.bitbucketbot.domain.entity;
|
package org.sadtech.bot.bitbucketbot.domain.entity;
|
||||||
|
|
||||||
import com.tsc.bitbucketbot.domain.ReviewerStatus;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.ReviewerStatus;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.domain.entity;
|
package org.sadtech.bot.bitbucketbot.domain.entity;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.domain.entity;
|
package org.sadtech.bot.bitbucketbot.domain.entity;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
@ -1,8 +1,8 @@
|
|||||||
package com.tsc.bitbucketbot.domain.util;
|
package org.sadtech.bot.bitbucketbot.domain.util;
|
||||||
|
|
||||||
import com.tsc.bitbucketbot.domain.ReviewerStatus;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.ReviewerStatus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Добавить описание класса.
|
* TODO: Добавить описание класса.
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.dto;
|
package org.sadtech.bot.bitbucketbot.dto;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
@ -1,8 +1,8 @@
|
|||||||
package com.tsc.bitbucketbot.dto.bitbucket;
|
package org.sadtech.bot.bitbucketbot.dto.bitbucket;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||||
import com.tsc.bitbucketbot.utils.LocalDateTimeFromEpochDeserializer;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import org.sadtech.bot.bitbucketbot.utils.LocalDateTimeFromEpochDeserializer;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.dto.bitbucket;
|
package org.sadtech.bot.bitbucketbot.dto.bitbucket;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.dto.bitbucket;
|
package org.sadtech.bot.bitbucketbot.dto.bitbucket;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.dto.bitbucket;
|
package org.sadtech.bot.bitbucketbot.dto.bitbucket;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.dto.bitbucket;
|
package org.sadtech.bot.bitbucketbot.dto.bitbucket;
|
||||||
|
|
||||||
public enum Outcome {
|
public enum Outcome {
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.dto.bitbucket;
|
package org.sadtech.bot.bitbucketbot.dto.bitbucket;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.dto.bitbucket;
|
package org.sadtech.bot.bitbucketbot.dto.bitbucket;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
package com.tsc.bitbucketbot.dto.bitbucket;
|
package org.sadtech.bot.bitbucketbot.dto.bitbucket;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||||
import com.tsc.bitbucketbot.utils.LocalDateTimeFromEpochDeserializer;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import org.sadtech.bot.bitbucketbot.utils.LocalDateTimeFromEpochDeserializer;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.dto.bitbucket;
|
package org.sadtech.bot.bitbucketbot.dto.bitbucket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Добавить комментарий енума.
|
* TODO: Добавить комментарий енума.
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.dto.bitbucket;
|
package org.sadtech.bot.bitbucketbot.dto.bitbucket;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.dto.bitbucket;
|
package org.sadtech.bot.bitbucketbot.dto.bitbucket;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.dto.bitbucket;
|
package org.sadtech.bot.bitbucketbot.dto.bitbucket;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
package com.tsc.bitbucketbot.dto.bitbucket;
|
package org.sadtech.bot.bitbucketbot.dto.bitbucket;
|
||||||
|
|
||||||
import com.tsc.bitbucketbot.domain.BitbucketUserRole;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.BitbucketUserRole;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Добавить описание класса.
|
* TODO: Добавить описание класса.
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.dto.bitbucket;
|
package org.sadtech.bot.bitbucketbot.dto.bitbucket;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.dto.bitbucket;
|
package org.sadtech.bot.bitbucketbot.dto.bitbucket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Добавить комментарий енума.
|
* TODO: Добавить комментарий енума.
|
@ -0,0 +1,13 @@
|
|||||||
|
package org.sadtech.bot.bitbucketbot.dto.bitbucket.sheet;
|
||||||
|
|
||||||
|
import org.sadtech.bot.bitbucketbot.dto.bitbucket.PullRequestJson;
|
||||||
|
import org.sadtech.bot.bitbucketbot.dto.bitbucket.Sheet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Добавить описание класса.
|
||||||
|
*
|
||||||
|
* @author upagge [02.02.2020]
|
||||||
|
*/
|
||||||
|
public class PullRequestSheetJson extends Sheet<PullRequestJson> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package org.sadtech.bot.bitbucketbot.dto.bitbucket.sheet;
|
||||||
|
|
||||||
|
import org.sadtech.bot.bitbucketbot.dto.bitbucket.Sheet;
|
||||||
|
import org.sadtech.bot.bitbucketbot.dto.bitbucket.UserJson;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Добавить описание класса.
|
||||||
|
*
|
||||||
|
* @author upagge [02.02.2020]
|
||||||
|
*/
|
||||||
|
public class UserSheetJson extends Sheet<UserJson> {
|
||||||
|
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.exception;
|
package org.sadtech.bot.bitbucketbot.exception;
|
||||||
|
|
||||||
class BitbucketBotException extends RuntimeException {
|
class BitbucketBotException extends RuntimeException {
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.exception;
|
package org.sadtech.bot.bitbucketbot.exception;
|
||||||
|
|
||||||
public class NotFoundException extends BitbucketBotException {
|
public class NotFoundException extends BitbucketBotException {
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.exception;
|
package org.sadtech.bot.bitbucketbot.exception;
|
||||||
|
|
||||||
public class RegException extends BitbucketBotException {
|
public class RegException extends BitbucketBotException {
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
package com.tsc.bitbucketbot.repository;
|
package org.sadtech.bot.bitbucketbot.repository;
|
||||||
|
|
||||||
import com.tsc.bitbucketbot.domain.change.Change;
|
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.change.Change;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
package com.tsc.bitbucketbot.repository;
|
package org.sadtech.bot.bitbucketbot.repository;
|
||||||
|
|
||||||
import com.tsc.bitbucketbot.domain.MessageSend;
|
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.MessageSend;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
@ -1,8 +1,8 @@
|
|||||||
package com.tsc.bitbucketbot.repository.impl;
|
package org.sadtech.bot.bitbucketbot.repository.impl;
|
||||||
|
|
||||||
import com.tsc.bitbucketbot.domain.change.Change;
|
|
||||||
import com.tsc.bitbucketbot.repository.ChangeRepository;
|
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.change.Change;
|
||||||
|
import org.sadtech.bot.bitbucketbot.repository.ChangeRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
@ -1,8 +1,8 @@
|
|||||||
package com.tsc.bitbucketbot.repository.impl;
|
package org.sadtech.bot.bitbucketbot.repository.impl;
|
||||||
|
|
||||||
import com.tsc.bitbucketbot.domain.MessageSend;
|
|
||||||
import com.tsc.bitbucketbot.repository.MessageSendRepository;
|
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.MessageSend;
|
||||||
|
import org.sadtech.bot.bitbucketbot.repository.MessageSendRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
@ -1,6 +1,6 @@
|
|||||||
package com.tsc.bitbucketbot.repository.jpa;
|
package org.sadtech.bot.bitbucketbot.repository.jpa;
|
||||||
|
|
||||||
import com.tsc.bitbucketbot.domain.entity.Comment;
|
import org.sadtech.bot.bitbucketbot.domain.entity.Comment;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
@ -1,9 +1,9 @@
|
|||||||
package com.tsc.bitbucketbot.repository.jpa;
|
package org.sadtech.bot.bitbucketbot.repository.jpa;
|
||||||
|
|
||||||
import com.tsc.bitbucketbot.domain.IdAndStatusPr;
|
import org.sadtech.bot.bitbucketbot.domain.IdAndStatusPr;
|
||||||
import com.tsc.bitbucketbot.domain.PullRequestStatus;
|
import org.sadtech.bot.bitbucketbot.domain.PullRequestStatus;
|
||||||
import com.tsc.bitbucketbot.domain.ReviewerStatus;
|
import org.sadtech.bot.bitbucketbot.domain.ReviewerStatus;
|
||||||
import com.tsc.bitbucketbot.domain.entity.PullRequest;
|
import org.sadtech.bot.bitbucketbot.domain.entity.PullRequest;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
import org.springframework.data.repository.query.Param;
|
import org.springframework.data.repository.query.Param;
|
||||||
@ -28,13 +28,13 @@ public interface PullRequestsRepository extends JpaRepository<PullRequest, Long>
|
|||||||
|
|
||||||
void deleteAllByIdIn(Collection<Long> id);
|
void deleteAllByIdIn(Collection<Long> id);
|
||||||
|
|
||||||
@Query("SELECT p FROM PullRequest p LEFT JOIN p.reviewers r WHERE r.user=:reviewer AND r.status =:status")
|
@Query("SELECT p FROM PullRequest p LEFT JOIN p.reviewers r WHERE r.user=:reviewer AND r.status =:reviewerStatus AND p.status IN :pullRequestStatus")
|
||||||
List<PullRequest> findAllByReviewerAndStatuses(@Param("reviewer") String reviewer, @Param("status") ReviewerStatus status);
|
List<PullRequest> findAllByReviewerAndStatuses(@Param("reviewer") String reviewer, @Param("reviewerStatus") ReviewerStatus reviewerStatus, @Param("pullRequestStatus") Set<PullRequestStatus> pullRequestStatus);
|
||||||
|
|
||||||
@Query("SELECT p FROM PullRequest p LEFT JOIN p.reviewers r WHERE p.author.login=:author AND r.status=:reviewerStatus")
|
@Query("SELECT p FROM PullRequest p LEFT JOIN p.reviewers r WHERE p.author.login=:author AND r.status=:reviewerStatus")
|
||||||
List<PullRequest> findAllByAuthorAndReviewerStatus(@Param("author") String author, @Param("reviewerStatus") ReviewerStatus reviewerStatus);
|
List<PullRequest> findAllByAuthorAndReviewerStatus(@Param("author") String author, @Param("reviewerStatus") ReviewerStatus reviewerStatus);
|
||||||
|
|
||||||
@Query("SELECT new com.tsc.bitbucketbot.domain.IdAndStatusPr(p.id, p.status) FROM PullRequest p WHERE p.status IN :statuses")
|
@Query("SELECT new org.sadtech.bot.bitbucketbot.domain.IdAndStatusPr(p.id, p.status) FROM PullRequest p WHERE p.status IN :statuses")
|
||||||
Set<IdAndStatusPr> findAllIdByStatusIn(@Param("statuses") Set<PullRequestStatus> statuses);
|
Set<IdAndStatusPr> findAllIdByStatusIn(@Param("statuses") Set<PullRequestStatus> statuses);
|
||||||
|
|
||||||
@Query("SELECT p.id from PullRequest p")
|
@Query("SELECT p.id from PullRequest p")
|
@ -1,6 +1,6 @@
|
|||||||
package com.tsc.bitbucketbot.repository.jpa;
|
package org.sadtech.bot.bitbucketbot.repository.jpa;
|
||||||
|
|
||||||
import com.tsc.bitbucketbot.domain.entity.User;
|
import org.sadtech.bot.bitbucketbot.domain.entity.User;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
@ -1,20 +1,20 @@
|
|||||||
package com.tsc.bitbucketbot.scheduler;
|
package org.sadtech.bot.bitbucketbot.scheduler;
|
||||||
|
|
||||||
import com.tsc.bitbucketbot.domain.MessageSend;
|
|
||||||
import com.tsc.bitbucketbot.domain.change.AnswerCommentChange;
|
|
||||||
import com.tsc.bitbucketbot.domain.change.Change;
|
|
||||||
import com.tsc.bitbucketbot.domain.change.CommentChange;
|
|
||||||
import com.tsc.bitbucketbot.domain.change.ConflictPrChange;
|
|
||||||
import com.tsc.bitbucketbot.domain.change.NewPrChange;
|
|
||||||
import com.tsc.bitbucketbot.domain.change.ReviewersPrChange;
|
|
||||||
import com.tsc.bitbucketbot.domain.change.StatusPrChange;
|
|
||||||
import com.tsc.bitbucketbot.domain.change.UpdatePrChange;
|
|
||||||
import com.tsc.bitbucketbot.exception.NotFoundException;
|
|
||||||
import com.tsc.bitbucketbot.service.ChangeService;
|
|
||||||
import com.tsc.bitbucketbot.service.MessageSendService;
|
|
||||||
import com.tsc.bitbucketbot.utils.Message;
|
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.MessageSend;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.change.AnswerCommentChange;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.change.Change;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.change.CommentChange;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.change.ConflictPrChange;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.change.NewPrChange;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.change.ReviewersPrChange;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.change.StatusPrChange;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.change.UpdatePrChange;
|
||||||
|
import org.sadtech.bot.bitbucketbot.exception.NotFoundException;
|
||||||
|
import org.sadtech.bot.bitbucketbot.service.ChangeService;
|
||||||
|
import org.sadtech.bot.bitbucketbot.service.MessageSendService;
|
||||||
|
import org.sadtech.bot.bitbucketbot.utils.Message;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
@ -1,24 +1,24 @@
|
|||||||
package com.tsc.bitbucketbot.scheduler;
|
package org.sadtech.bot.bitbucketbot.scheduler;
|
||||||
|
|
||||||
import com.tsc.bitbucketbot.config.BitbucketConfig;
|
|
||||||
import com.tsc.bitbucketbot.domain.Answer;
|
|
||||||
import com.tsc.bitbucketbot.domain.Pagination;
|
|
||||||
import com.tsc.bitbucketbot.domain.change.AnswerCommentChange;
|
|
||||||
import com.tsc.bitbucketbot.domain.change.CommentChange;
|
|
||||||
import com.tsc.bitbucketbot.domain.entity.Comment;
|
|
||||||
import com.tsc.bitbucketbot.domain.entity.PullRequest;
|
|
||||||
import com.tsc.bitbucketbot.dto.bitbucket.CommentJson;
|
|
||||||
import com.tsc.bitbucketbot.service.ChangeService;
|
|
||||||
import com.tsc.bitbucketbot.service.CommentService;
|
|
||||||
import com.tsc.bitbucketbot.service.PullRequestsService;
|
|
||||||
import com.tsc.bitbucketbot.service.UserService;
|
|
||||||
import com.tsc.bitbucketbot.service.Utils;
|
|
||||||
import com.tsc.bitbucketbot.service.executor.DataScan;
|
|
||||||
import com.tsc.bitbucketbot.service.executor.ResultScan;
|
|
||||||
import com.tsc.bitbucketbot.service.impl.ExecutorScanner;
|
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.sadtech.bot.bitbucketbot.config.BitbucketConfig;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.Answer;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.Pagination;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.change.AnswerCommentChange;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.change.CommentChange;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.entity.Comment;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.entity.PullRequest;
|
||||||
|
import org.sadtech.bot.bitbucketbot.dto.bitbucket.CommentJson;
|
||||||
|
import org.sadtech.bot.bitbucketbot.service.ChangeService;
|
||||||
|
import org.sadtech.bot.bitbucketbot.service.CommentService;
|
||||||
|
import org.sadtech.bot.bitbucketbot.service.PullRequestsService;
|
||||||
|
import org.sadtech.bot.bitbucketbot.service.UserService;
|
||||||
|
import org.sadtech.bot.bitbucketbot.service.Utils;
|
||||||
|
import org.sadtech.bot.bitbucketbot.service.executor.DataScan;
|
||||||
|
import org.sadtech.bot.bitbucketbot.service.executor.ResultScan;
|
||||||
|
import org.sadtech.bot.bitbucketbot.service.impl.ExecutorScanner;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -51,7 +51,7 @@ public class SchedulerComments {
|
|||||||
|
|
||||||
private final BitbucketConfig bitbucketConfig;
|
private final BitbucketConfig bitbucketConfig;
|
||||||
|
|
||||||
@Scheduled(cron = "0 */1 * * * MON-FRI")
|
@Scheduled(cron = "0 */3 * * * MON-FRI")
|
||||||
public void newComments() {
|
public void newComments() {
|
||||||
long commentId = commentService.getLastCommentId() + 1;
|
long commentId = commentService.getLastCommentId() + 1;
|
||||||
int count = 0;
|
int count = 0;
|
@ -1,12 +1,12 @@
|
|||||||
package com.tsc.bitbucketbot.scheduler;
|
package org.sadtech.bot.bitbucketbot.scheduler;
|
||||||
|
|
||||||
import com.tsc.bitbucketbot.config.BitbucketConfig;
|
|
||||||
import com.tsc.bitbucketbot.domain.entity.User;
|
|
||||||
import com.tsc.bitbucketbot.dto.bitbucket.UserJson;
|
|
||||||
import com.tsc.bitbucketbot.dto.bitbucket.sheet.UserSheetJson;
|
|
||||||
import com.tsc.bitbucketbot.service.UserService;
|
|
||||||
import com.tsc.bitbucketbot.service.Utils;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.sadtech.bot.bitbucketbot.config.BitbucketConfig;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.entity.User;
|
||||||
|
import org.sadtech.bot.bitbucketbot.dto.bitbucket.UserJson;
|
||||||
|
import org.sadtech.bot.bitbucketbot.dto.bitbucket.sheet.UserSheetJson;
|
||||||
|
import org.sadtech.bot.bitbucketbot.service.UserService;
|
||||||
|
import org.sadtech.bot.bitbucketbot.service.Utils;
|
||||||
import org.springframework.core.convert.ConversionService;
|
import org.springframework.core.convert.ConversionService;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
@ -1,24 +1,29 @@
|
|||||||
package com.tsc.bitbucketbot.scheduler;
|
package org.sadtech.bot.bitbucketbot.scheduler;
|
||||||
|
|
||||||
import com.tsc.bitbucketbot.domain.MessageSend;
|
|
||||||
import com.tsc.bitbucketbot.domain.ReviewerStatus;
|
|
||||||
import com.tsc.bitbucketbot.domain.entity.PullRequest;
|
|
||||||
import com.tsc.bitbucketbot.domain.entity.User;
|
|
||||||
import com.tsc.bitbucketbot.service.MessageSendService;
|
|
||||||
import com.tsc.bitbucketbot.service.PullRequestsService;
|
|
||||||
import com.tsc.bitbucketbot.service.ReportService;
|
|
||||||
import com.tsc.bitbucketbot.service.UserService;
|
|
||||||
import com.tsc.bitbucketbot.utils.Message;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.MessageSend;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.PullRequestStatus;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.ReviewerStatus;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.entity.PullRequest;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.entity.User;
|
||||||
|
import org.sadtech.bot.bitbucketbot.service.MessageSendService;
|
||||||
|
import org.sadtech.bot.bitbucketbot.service.PullRequestsService;
|
||||||
|
import org.sadtech.bot.bitbucketbot.service.ReportService;
|
||||||
|
import org.sadtech.bot.bitbucketbot.service.UserService;
|
||||||
|
import org.sadtech.bot.bitbucketbot.utils.Message;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class SchedulerNotification {
|
public class SchedulerNotification {
|
||||||
|
|
||||||
|
private static final Set<PullRequestStatus> statuses = Collections.singleton(PullRequestStatus.OPEN);
|
||||||
|
|
||||||
private final UserService userService;
|
private final UserService userService;
|
||||||
private final PullRequestsService pullRequestsService;
|
private final PullRequestsService pullRequestsService;
|
||||||
private final MessageSendService messageSendService;
|
private final MessageSendService messageSendService;
|
||||||
@ -31,7 +36,8 @@ public class SchedulerNotification {
|
|||||||
for (User user : allRegister) {
|
for (User user : allRegister) {
|
||||||
List<PullRequest> pullRequestsReviews = pullRequestsService.getAllByReviewerAndStatuses(
|
List<PullRequest> pullRequestsReviews = pullRequestsService.getAllByReviewerAndStatuses(
|
||||||
user.getLogin(),
|
user.getLogin(),
|
||||||
ReviewerStatus.NEEDS_WORK
|
ReviewerStatus.NEEDS_WORK,
|
||||||
|
statuses
|
||||||
);
|
);
|
||||||
List<PullRequest> pullRequestsNeedWork = pullRequestsService.getAllByAuthorAndReviewerStatus(user.getLogin(), ReviewerStatus.UNAPPROVED);
|
List<PullRequest> pullRequestsNeedWork = pullRequestsService.getAllByAuthorAndReviewerStatus(user.getLogin(), ReviewerStatus.UNAPPROVED);
|
||||||
messageSendService.add(
|
messageSendService.add(
|
@ -1,34 +1,36 @@
|
|||||||
package com.tsc.bitbucketbot.scheduler;
|
package org.sadtech.bot.bitbucketbot.scheduler;
|
||||||
|
|
||||||
import com.tsc.bitbucketbot.config.BitbucketConfig;
|
|
||||||
import com.tsc.bitbucketbot.domain.IdAndStatusPr;
|
|
||||||
import com.tsc.bitbucketbot.domain.PullRequestStatus;
|
|
||||||
import com.tsc.bitbucketbot.domain.ReviewerStatus;
|
|
||||||
import com.tsc.bitbucketbot.domain.change.ConflictPrChange;
|
|
||||||
import com.tsc.bitbucketbot.domain.change.NewPrChange;
|
|
||||||
import com.tsc.bitbucketbot.domain.change.ReviewersPrChange;
|
|
||||||
import com.tsc.bitbucketbot.domain.change.StatusPrChange;
|
|
||||||
import com.tsc.bitbucketbot.domain.change.UpdatePrChange;
|
|
||||||
import com.tsc.bitbucketbot.domain.entity.PullRequest;
|
|
||||||
import com.tsc.bitbucketbot.domain.entity.Reviewer;
|
|
||||||
import com.tsc.bitbucketbot.domain.entity.User;
|
|
||||||
import com.tsc.bitbucketbot.domain.util.ReviewerChange;
|
|
||||||
import com.tsc.bitbucketbot.dto.bitbucket.PullRequestJson;
|
|
||||||
import com.tsc.bitbucketbot.dto.bitbucket.sheet.PullRequestSheetJson;
|
|
||||||
import com.tsc.bitbucketbot.service.ChangeService;
|
|
||||||
import com.tsc.bitbucketbot.service.PullRequestsService;
|
|
||||||
import com.tsc.bitbucketbot.service.UserService;
|
|
||||||
import com.tsc.bitbucketbot.service.Utils;
|
|
||||||
import com.tsc.bitbucketbot.utils.NonNullUtils;
|
|
||||||
import com.tsc.bitbucketbot.utils.Pair;
|
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.sadtech.bot.bitbucketbot.config.BitbucketConfig;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.IdAndStatusPr;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.PullRequestStatus;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.ReviewerStatus;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.change.ConflictPrChange;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.change.NewPrChange;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.change.ReviewersPrChange;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.change.StatusPrChange;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.change.UpdatePrChange;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.entity.PullRequest;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.entity.Reviewer;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.entity.User;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.util.ReviewerChange;
|
||||||
|
import org.sadtech.bot.bitbucketbot.dto.bitbucket.PullRequestJson;
|
||||||
|
import org.sadtech.bot.bitbucketbot.dto.bitbucket.sheet.PullRequestSheetJson;
|
||||||
|
import org.sadtech.bot.bitbucketbot.service.ChangeService;
|
||||||
|
import org.sadtech.bot.bitbucketbot.service.PullRequestsService;
|
||||||
|
import org.sadtech.bot.bitbucketbot.service.UserService;
|
||||||
|
import org.sadtech.bot.bitbucketbot.service.Utils;
|
||||||
|
import org.sadtech.bot.bitbucketbot.utils.NonNullUtils;
|
||||||
|
import org.sadtech.bot.bitbucketbot.utils.Pair;
|
||||||
import org.springframework.core.convert.ConversionService;
|
import org.springframework.core.convert.ConversionService;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -39,14 +41,15 @@ import java.util.Set;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static com.tsc.bitbucketbot.domain.PullRequestStatus.DECLINED;
|
import static org.sadtech.bot.bitbucketbot.domain.PullRequestStatus.DECLINED;
|
||||||
import static com.tsc.bitbucketbot.domain.PullRequestStatus.DELETE;
|
import static org.sadtech.bot.bitbucketbot.domain.PullRequestStatus.DELETE;
|
||||||
import static com.tsc.bitbucketbot.domain.PullRequestStatus.MERGED;
|
import static org.sadtech.bot.bitbucketbot.domain.PullRequestStatus.MERGED;
|
||||||
import static com.tsc.bitbucketbot.domain.PullRequestStatus.OPEN;
|
import static org.sadtech.bot.bitbucketbot.domain.PullRequestStatus.OPEN;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author upagge [30.01.2020]
|
* @author upagge [30.01.2020]
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class SchedulerPullRequest {
|
public class SchedulerPullRequest {
|
||||||
@ -65,10 +68,13 @@ public class SchedulerPullRequest {
|
|||||||
.map(IdAndStatusPr::getId)
|
.map(IdAndStatusPr::getId)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
final Set<Long> openId = checkOpenPullRequest();
|
final Set<Long> openId = checkOpenPullRequest();
|
||||||
|
log.info("Открыты: " + Arrays.toString(openId.toArray()));
|
||||||
final Set<Long> closeId = checkClosePullRequest();
|
final Set<Long> closeId = checkClosePullRequest();
|
||||||
|
log.info("Закрыты: " + Arrays.toString(closeId.toArray()));
|
||||||
final Set<Long> newNotExistsId = existsId.stream()
|
final Set<Long> newNotExistsId = existsId.stream()
|
||||||
.filter(id -> !openId.contains(id) && !closeId.contains(id))
|
.filter(id -> !openId.contains(id) && !closeId.contains(id))
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
log.info("Не найдены: " + Arrays.toString(newNotExistsId.toArray()));
|
||||||
if (!newNotExistsId.isEmpty()) {
|
if (!newNotExistsId.isEmpty()) {
|
||||||
updateDeletePr(newNotExistsId);
|
updateDeletePr(newNotExistsId);
|
||||||
}
|
}
|
@ -1,10 +1,7 @@
|
|||||||
package com.tsc.bitbucketbot.scheduler;
|
package org.sadtech.bot.bitbucketbot.scheduler;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.tsc.bitbucketbot.config.PushMessageConfig;
|
|
||||||
import com.tsc.bitbucketbot.domain.MessageSend;
|
|
||||||
import com.tsc.bitbucketbot.service.MessageSendService;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import okhttp3.Authenticator;
|
import okhttp3.Authenticator;
|
||||||
@ -14,6 +11,9 @@ import okhttp3.OkHttpClient;
|
|||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.RequestBody;
|
import okhttp3.RequestBody;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
import org.sadtech.bot.bitbucketbot.config.PushMessageConfig;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.MessageSend;
|
||||||
|
import org.sadtech.bot.bitbucketbot.service.MessageSendService;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@ -22,7 +22,6 @@ import java.io.IOException;
|
|||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.Proxy;
|
import java.net.Proxy;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@ -51,15 +50,12 @@ public class SchedulerPushMessageSend {
|
|||||||
};
|
};
|
||||||
|
|
||||||
client = new OkHttpClient.Builder()
|
client = new OkHttpClient.Builder()
|
||||||
.connectTimeout(60, TimeUnit.SECONDS)
|
|
||||||
.writeTimeout(60, TimeUnit.SECONDS)
|
|
||||||
.readTimeout(60, TimeUnit.SECONDS)
|
|
||||||
.proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort)))
|
.proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort)))
|
||||||
.proxyAuthenticator(proxyAuthenticator)
|
.proxyAuthenticator(proxyAuthenticator)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Scheduled(fixedDelay = 15000)
|
@Scheduled(fixedDelay = 30000)
|
||||||
public void sendNewMessage() {
|
public void sendNewMessage() {
|
||||||
List<MessageSend> pushMessage = messageSendService.getPushMessage();
|
List<MessageSend> pushMessage = messageSendService.getPushMessage();
|
||||||
if (!pushMessage.isEmpty()) {
|
if (!pushMessage.isEmpty()) {
|
||||||
@ -72,7 +68,6 @@ public class SchedulerPushMessageSend {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void sendMessage(String json) {
|
private void sendMessage(String json) {
|
||||||
System.out.println(json);
|
|
||||||
RequestBody body = RequestBody.create(JSON, json);
|
RequestBody body = RequestBody.create(JSON, json);
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
.url(pushMessageConfig.getUrl())
|
.url(pushMessageConfig.getUrl())
|
@ -1,7 +1,7 @@
|
|||||||
package com.tsc.bitbucketbot.service;
|
package org.sadtech.bot.bitbucketbot.service;
|
||||||
|
|
||||||
import com.tsc.bitbucketbot.domain.change.Change;
|
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.change.Change;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
package com.tsc.bitbucketbot.service;
|
package org.sadtech.bot.bitbucketbot.service;
|
||||||
|
|
||||||
import com.tsc.bitbucketbot.domain.Pagination;
|
|
||||||
import com.tsc.bitbucketbot.domain.entity.Comment;
|
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.Pagination;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.entity.Comment;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
@ -1,7 +1,7 @@
|
|||||||
package com.tsc.bitbucketbot.service;
|
package org.sadtech.bot.bitbucketbot.service;
|
||||||
|
|
||||||
import com.tsc.bitbucketbot.domain.MessageSend;
|
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.MessageSend;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -1,11 +1,11 @@
|
|||||||
package com.tsc.bitbucketbot.service;
|
package org.sadtech.bot.bitbucketbot.service;
|
||||||
|
|
||||||
import com.tsc.bitbucketbot.domain.IdAndStatusPr;
|
|
||||||
import com.tsc.bitbucketbot.domain.Pagination;
|
|
||||||
import com.tsc.bitbucketbot.domain.PullRequestStatus;
|
|
||||||
import com.tsc.bitbucketbot.domain.ReviewerStatus;
|
|
||||||
import com.tsc.bitbucketbot.domain.entity.PullRequest;
|
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.IdAndStatusPr;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.Pagination;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.PullRequestStatus;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.ReviewerStatus;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.entity.PullRequest;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@ -31,7 +31,7 @@ public interface PullRequestsService {
|
|||||||
void deleteAll(@NonNull Set<Long> id);
|
void deleteAll(@NonNull Set<Long> id);
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
List<PullRequest> getAllByReviewerAndStatuses(String login, ReviewerStatus statuses);
|
List<PullRequest> getAllByReviewerAndStatuses(@NonNull String login, @NonNull ReviewerStatus reviewerStatus, @NonNull Set<PullRequestStatus> pullRequestStatuses);
|
||||||
|
|
||||||
List<PullRequest> getAllByAuthorAndReviewerStatus(@NonNull String login, @NonNull ReviewerStatus status);
|
List<PullRequest> getAllByAuthorAndReviewerStatus(@NonNull String login, @NonNull ReviewerStatus status);
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.service;
|
package org.sadtech.bot.bitbucketbot.service;
|
||||||
|
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
package com.tsc.bitbucketbot.service;
|
package org.sadtech.bot.bitbucketbot.service;
|
||||||
|
|
||||||
import com.tsc.bitbucketbot.domain.entity.User;
|
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.entity.User;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
@ -0,0 +1,54 @@
|
|||||||
|
package org.sadtech.bot.bitbucketbot.service;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import lombok.NonNull;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
import okhttp3.Request;
|
||||||
|
import okhttp3.Response;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author upagge [30.01.2020]
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class Utils {
|
||||||
|
|
||||||
|
private static ObjectMapper objectMapper;
|
||||||
|
|
||||||
|
static {
|
||||||
|
objectMapper = new ObjectMapper();
|
||||||
|
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final OkHttpClient client = new OkHttpClient.Builder()
|
||||||
|
.connectTimeout(60, TimeUnit.SECONDS)
|
||||||
|
.writeTimeout(60, TimeUnit.SECONDS)
|
||||||
|
.readTimeout(60, TimeUnit.SECONDS)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
private Utils() {
|
||||||
|
throw new IllegalStateException("Утилитарный класс");
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public static <T> Optional<T> urlToJson(String urlValue, String token, Class<T> classOfT) {
|
||||||
|
Request request = new Request.Builder()
|
||||||
|
.url(urlValue)
|
||||||
|
.header("Authorization", "Bearer " + token)
|
||||||
|
.build();
|
||||||
|
try (final Response execute = client.newCall(request).execute()) {
|
||||||
|
if (execute.isSuccessful() && execute.body() != null) {
|
||||||
|
return Optional.ofNullable(objectMapper.readValue(execute.body().string(), classOfT));
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
|
}
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,19 +1,19 @@
|
|||||||
package com.tsc.bitbucketbot.service.converter;
|
package org.sadtech.bot.bitbucketbot.service.converter;
|
||||||
|
|
||||||
import com.tsc.bitbucketbot.domain.PullRequestStatus;
|
|
||||||
import com.tsc.bitbucketbot.domain.ReviewerStatus;
|
|
||||||
import com.tsc.bitbucketbot.domain.entity.PullRequest;
|
|
||||||
import com.tsc.bitbucketbot.domain.entity.Reviewer;
|
|
||||||
import com.tsc.bitbucketbot.domain.entity.User;
|
|
||||||
import com.tsc.bitbucketbot.dto.bitbucket.Outcome;
|
|
||||||
import com.tsc.bitbucketbot.dto.bitbucket.Properties;
|
|
||||||
import com.tsc.bitbucketbot.dto.bitbucket.PullRequestJson;
|
|
||||||
import com.tsc.bitbucketbot.dto.bitbucket.PullRequestState;
|
|
||||||
import com.tsc.bitbucketbot.dto.bitbucket.UserDecisionJson;
|
|
||||||
import com.tsc.bitbucketbot.dto.bitbucket.UserJson;
|
|
||||||
import com.tsc.bitbucketbot.dto.bitbucket.UserPullRequestStatus;
|
|
||||||
import com.tsc.bitbucketbot.service.UserService;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.PullRequestStatus;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.ReviewerStatus;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.entity.PullRequest;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.entity.Reviewer;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.entity.User;
|
||||||
|
import org.sadtech.bot.bitbucketbot.dto.bitbucket.Outcome;
|
||||||
|
import org.sadtech.bot.bitbucketbot.dto.bitbucket.Properties;
|
||||||
|
import org.sadtech.bot.bitbucketbot.dto.bitbucket.PullRequestJson;
|
||||||
|
import org.sadtech.bot.bitbucketbot.dto.bitbucket.PullRequestState;
|
||||||
|
import org.sadtech.bot.bitbucketbot.dto.bitbucket.UserDecisionJson;
|
||||||
|
import org.sadtech.bot.bitbucketbot.dto.bitbucket.UserJson;
|
||||||
|
import org.sadtech.bot.bitbucketbot.dto.bitbucket.UserPullRequestStatus;
|
||||||
|
import org.sadtech.bot.bitbucketbot.service.UserService;
|
||||||
import org.springframework.core.convert.converter.Converter;
|
import org.springframework.core.convert.converter.Converter;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
package com.tsc.bitbucketbot.service.converter;
|
package org.sadtech.bot.bitbucketbot.service.converter;
|
||||||
|
|
||||||
import com.tsc.bitbucketbot.domain.entity.User;
|
import org.sadtech.bot.bitbucketbot.domain.entity.User;
|
||||||
import com.tsc.bitbucketbot.dto.UserDto;
|
import org.sadtech.bot.bitbucketbot.dto.UserDto;
|
||||||
import org.springframework.core.convert.converter.Converter;
|
import org.springframework.core.convert.converter.Converter;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
package com.tsc.bitbucketbot.service.converter;
|
package org.sadtech.bot.bitbucketbot.service.converter;
|
||||||
|
|
||||||
import com.tsc.bitbucketbot.domain.entity.User;
|
import org.sadtech.bot.bitbucketbot.domain.entity.User;
|
||||||
import com.tsc.bitbucketbot.dto.bitbucket.UserJson;
|
import org.sadtech.bot.bitbucketbot.dto.bitbucket.UserJson;
|
||||||
import org.springframework.core.convert.converter.Converter;
|
import org.springframework.core.convert.converter.Converter;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.service.executor;
|
package org.sadtech.bot.bitbucketbot.service.executor;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.service.executor;
|
package org.sadtech.bot.bitbucketbot.service.executor;
|
||||||
|
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
package com.tsc.bitbucketbot.service.executor;
|
package org.sadtech.bot.bitbucketbot.service.executor;
|
||||||
|
|
||||||
import com.tsc.bitbucketbot.dto.bitbucket.CommentJson;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import org.sadtech.bot.bitbucketbot.dto.bitbucket.CommentJson;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class ResultScan {
|
public class ResultScan {
|
@ -0,0 +1,25 @@
|
|||||||
|
package org.sadtech.bot.bitbucketbot.service.executor;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.sadtech.bot.bitbucketbot.dto.bitbucket.CommentJson;
|
||||||
|
import org.sadtech.bot.bitbucketbot.service.Utils;
|
||||||
|
|
||||||
|
import java.security.SecureRandom;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class Seeker implements Callable<Optional<ResultScan>> {
|
||||||
|
|
||||||
|
private static final SecureRandom random = new SecureRandom();
|
||||||
|
private final DataScan dataScan;
|
||||||
|
private final String token;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<ResultScan> call() throws Exception {
|
||||||
|
// Thread.sleep(random.nextInt(500) + 500L);
|
||||||
|
return Utils.urlToJson(dataScan.getUrlComment(), token, CommentJson.class)
|
||||||
|
.map(commentJson -> new ResultScan(dataScan.getUrlComment(), dataScan.getUrlPr(), commentJson));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,10 +1,10 @@
|
|||||||
package com.tsc.bitbucketbot.service.impl;
|
package org.sadtech.bot.bitbucketbot.service.impl;
|
||||||
|
|
||||||
import com.tsc.bitbucketbot.domain.change.Change;
|
|
||||||
import com.tsc.bitbucketbot.repository.ChangeRepository;
|
|
||||||
import com.tsc.bitbucketbot.service.ChangeService;
|
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.change.Change;
|
||||||
|
import org.sadtech.bot.bitbucketbot.repository.ChangeRepository;
|
||||||
|
import org.sadtech.bot.bitbucketbot.service.ChangeService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
@ -1,12 +1,12 @@
|
|||||||
package com.tsc.bitbucketbot.service.impl;
|
package org.sadtech.bot.bitbucketbot.service.impl;
|
||||||
|
|
||||||
import com.tsc.bitbucketbot.config.InitConfig;
|
|
||||||
import com.tsc.bitbucketbot.domain.Pagination;
|
|
||||||
import com.tsc.bitbucketbot.domain.entity.Comment;
|
|
||||||
import com.tsc.bitbucketbot.repository.jpa.CommentRepository;
|
|
||||||
import com.tsc.bitbucketbot.service.CommentService;
|
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.sadtech.bot.bitbucketbot.config.InitConfig;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.Pagination;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.entity.Comment;
|
||||||
|
import org.sadtech.bot.bitbucketbot.repository.jpa.CommentRepository;
|
||||||
|
import org.sadtech.bot.bitbucketbot.service.CommentService;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
@ -1,20 +1,18 @@
|
|||||||
package com.tsc.bitbucketbot.service.impl;
|
package org.sadtech.bot.bitbucketbot.service.impl;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.tsc.bitbucketbot.config.BitbucketConfig;
|
|
||||||
import com.tsc.bitbucketbot.service.executor.DataScan;
|
|
||||||
import com.tsc.bitbucketbot.service.executor.Executor;
|
|
||||||
import com.tsc.bitbucketbot.service.executor.ResultScan;
|
|
||||||
import com.tsc.bitbucketbot.service.executor.Seeker;
|
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.sadtech.bot.bitbucketbot.config.BitbucketConfig;
|
||||||
|
import org.sadtech.bot.bitbucketbot.service.executor.DataScan;
|
||||||
|
import org.sadtech.bot.bitbucketbot.service.executor.Executor;
|
||||||
|
import org.sadtech.bot.bitbucketbot.service.executor.ResultScan;
|
||||||
|
import org.sadtech.bot.bitbucketbot.service.executor.Seeker;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
@ -26,14 +24,14 @@ import java.util.stream.Collectors;
|
|||||||
public class ExecutorScanner implements Executor<DataScan, ResultScan> {
|
public class ExecutorScanner implements Executor<DataScan, ResultScan> {
|
||||||
|
|
||||||
private final ExecutorService executorService;
|
private final ExecutorService executorService;
|
||||||
private final List<Future<List<ResultScan>>> resultList = new ArrayList<>();
|
private final List<Future<Optional<ResultScan>>> resultList = new ArrayList<>();
|
||||||
private final BitbucketConfig bitbucketConfig;
|
private final BitbucketConfig bitbucketConfig;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean registration(@NonNull List<DataScan> dataScans) {
|
public boolean registration(@NonNull List<DataScan> dataScans) {
|
||||||
Lists.partition(dataScans, 20).forEach(
|
dataScans.stream()
|
||||||
list -> resultList.add(executorService.submit(new Seeker(list, bitbucketConfig.getToken())))
|
.map(dataScan -> new Seeker(dataScan, bitbucketConfig.getToken()))
|
||||||
);
|
.forEach(seeker -> executorService.submit(seeker));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,21 +42,21 @@ public class ExecutorScanner implements Executor<DataScan, ResultScan> {
|
|||||||
}
|
}
|
||||||
final List<ResultScan> result = resultList.stream()
|
final List<ResultScan> result = resultList.stream()
|
||||||
.filter(Future::isDone)
|
.filter(Future::isDone)
|
||||||
.map(this::getResultScans)
|
.map(this::getResultScan)
|
||||||
.flatMap(Collection::stream)
|
.filter(Optional::isPresent)
|
||||||
|
.map(Optional::get)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
resultList.clear();
|
resultList.clear();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ResultScan> getResultScans(Future<List<ResultScan>> listFuture) {
|
private Optional<ResultScan> getResultScan(Future<Optional<ResultScan>> test) {
|
||||||
try {
|
try {
|
||||||
return listFuture.get();
|
return test.get();
|
||||||
} catch (InterruptedException | ExecutionException e) {
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
log.error(e.getMessage());
|
log.error(e.getMessage());
|
||||||
}
|
}
|
||||||
return Collections.emptyList();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -1,10 +1,10 @@
|
|||||||
package com.tsc.bitbucketbot.service.impl;
|
package org.sadtech.bot.bitbucketbot.service.impl;
|
||||||
|
|
||||||
import com.tsc.bitbucketbot.domain.MessageSend;
|
|
||||||
import com.tsc.bitbucketbot.repository.MessageSendRepository;
|
|
||||||
import com.tsc.bitbucketbot.service.MessageSendService;
|
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.MessageSend;
|
||||||
|
import org.sadtech.bot.bitbucketbot.repository.MessageSendRepository;
|
||||||
|
import org.sadtech.bot.bitbucketbot.service.MessageSendService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
@ -1,14 +1,14 @@
|
|||||||
package com.tsc.bitbucketbot.service.impl;
|
package org.sadtech.bot.bitbucketbot.service.impl;
|
||||||
|
|
||||||
import com.tsc.bitbucketbot.domain.IdAndStatusPr;
|
|
||||||
import com.tsc.bitbucketbot.domain.Pagination;
|
|
||||||
import com.tsc.bitbucketbot.domain.PullRequestStatus;
|
|
||||||
import com.tsc.bitbucketbot.domain.ReviewerStatus;
|
|
||||||
import com.tsc.bitbucketbot.domain.entity.PullRequest;
|
|
||||||
import com.tsc.bitbucketbot.repository.jpa.PullRequestsRepository;
|
|
||||||
import com.tsc.bitbucketbot.service.PullRequestsService;
|
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.IdAndStatusPr;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.Pagination;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.PullRequestStatus;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.ReviewerStatus;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.entity.PullRequest;
|
||||||
|
import org.sadtech.bot.bitbucketbot.repository.jpa.PullRequestsRepository;
|
||||||
|
import org.sadtech.bot.bitbucketbot.service.PullRequestsService;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -64,8 +64,8 @@ public class PullRequestsServiceImpl implements PullRequestsService {
|
|||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public List<PullRequest> getAllByReviewerAndStatuses(String login, ReviewerStatus reviewerStatus) {
|
public List<PullRequest> getAllByReviewerAndStatuses(String login, ReviewerStatus reviewerStatus, Set<PullRequestStatus> statuses) {
|
||||||
return pullRequestsRepository.findAllByReviewerAndStatuses(login, reviewerStatus);
|
return pullRequestsRepository.findAllByReviewerAndStatuses(login, reviewerStatus, statuses);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
@ -1,11 +1,11 @@
|
|||||||
package com.tsc.bitbucketbot.service.impl;
|
package org.sadtech.bot.bitbucketbot.service.impl;
|
||||||
|
|
||||||
import com.tsc.bitbucketbot.domain.entity.PullRequest;
|
|
||||||
import com.tsc.bitbucketbot.service.PullRequestsService;
|
|
||||||
import com.tsc.bitbucketbot.service.ReportService;
|
|
||||||
import com.tsc.bitbucketbot.utils.Smile;
|
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.entity.PullRequest;
|
||||||
|
import org.sadtech.bot.bitbucketbot.service.PullRequestsService;
|
||||||
|
import org.sadtech.bot.bitbucketbot.service.ReportService;
|
||||||
|
import org.sadtech.bot.bitbucketbot.utils.Smile;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
@ -1,14 +1,14 @@
|
|||||||
package com.tsc.bitbucketbot.service.impl;
|
package org.sadtech.bot.bitbucketbot.service.impl;
|
||||||
|
|
||||||
import com.tsc.bitbucketbot.config.BitbucketConfig;
|
|
||||||
import com.tsc.bitbucketbot.domain.entity.User;
|
|
||||||
import com.tsc.bitbucketbot.dto.bitbucket.sheet.PullRequestSheetJson;
|
|
||||||
import com.tsc.bitbucketbot.exception.RegException;
|
|
||||||
import com.tsc.bitbucketbot.repository.jpa.UserRepository;
|
|
||||||
import com.tsc.bitbucketbot.service.UserService;
|
|
||||||
import com.tsc.bitbucketbot.service.Utils;
|
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.sadtech.bot.bitbucketbot.config.BitbucketConfig;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.entity.User;
|
||||||
|
import org.sadtech.bot.bitbucketbot.dto.bitbucket.sheet.PullRequestSheetJson;
|
||||||
|
import org.sadtech.bot.bitbucketbot.exception.RegException;
|
||||||
|
import org.sadtech.bot.bitbucketbot.repository.jpa.UserRepository;
|
||||||
|
import org.sadtech.bot.bitbucketbot.service.UserService;
|
||||||
|
import org.sadtech.bot.bitbucketbot.service.Utils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.utils;
|
package org.sadtech.bot.bitbucketbot.utils;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonParser;
|
import com.fasterxml.jackson.core.JsonParser;
|
||||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
import com.fasterxml.jackson.databind.DeserializationContext;
|
@ -1,25 +1,25 @@
|
|||||||
package com.tsc.bitbucketbot.utils;
|
package org.sadtech.bot.bitbucketbot.utils;
|
||||||
|
|
||||||
import com.tsc.bitbucketbot.domain.change.AnswerCommentChange;
|
|
||||||
import com.tsc.bitbucketbot.domain.change.CommentChange;
|
|
||||||
import com.tsc.bitbucketbot.domain.change.ConflictPrChange;
|
|
||||||
import com.tsc.bitbucketbot.domain.change.NewPrChange;
|
|
||||||
import com.tsc.bitbucketbot.domain.change.ReviewersPrChange;
|
|
||||||
import com.tsc.bitbucketbot.domain.change.StatusPrChange;
|
|
||||||
import com.tsc.bitbucketbot.domain.change.UpdatePrChange;
|
|
||||||
import com.tsc.bitbucketbot.domain.entity.PullRequest;
|
|
||||||
import com.tsc.bitbucketbot.domain.util.ReviewerChange;
|
|
||||||
import com.tsc.bitbucketbot.dto.bitbucket.CommentJson;
|
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.change.AnswerCommentChange;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.change.CommentChange;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.change.ConflictPrChange;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.change.NewPrChange;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.change.ReviewersPrChange;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.change.StatusPrChange;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.change.UpdatePrChange;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.entity.PullRequest;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.util.ReviewerChange;
|
||||||
|
import org.sadtech.bot.bitbucketbot.dto.bitbucket.CommentJson;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static com.tsc.bitbucketbot.domain.util.ReviewerChange.Type.DELETED;
|
import static org.sadtech.bot.bitbucketbot.domain.util.ReviewerChange.Type.DELETED;
|
||||||
import static com.tsc.bitbucketbot.domain.util.ReviewerChange.Type.NEW;
|
import static org.sadtech.bot.bitbucketbot.domain.util.ReviewerChange.Type.NEW;
|
||||||
import static com.tsc.bitbucketbot.domain.util.ReviewerChange.Type.OLD;
|
import static org.sadtech.bot.bitbucketbot.domain.util.ReviewerChange.Type.OLD;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Генерирует сообщения для отправки.
|
* Генерирует сообщения для отправки.
|
@ -1,7 +1,7 @@
|
|||||||
package com.tsc.bitbucketbot.utils;
|
package org.sadtech.bot.bitbucketbot.utils;
|
||||||
|
|
||||||
import com.tsc.bitbucketbot.domain.entity.User;
|
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
|
import org.sadtech.bot.bitbucketbot.domain.entity.User;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.utils;
|
package org.sadtech.bot.bitbucketbot.utils;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
@ -1,4 +1,4 @@
|
|||||||
package com.tsc.bitbucketbot.utils;
|
package org.sadtech.bot.bitbucketbot.utils;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
@ -1,6 +1,6 @@
|
|||||||
package com.tsc.bitbucketbot.utils;
|
package org.sadtech.bot.bitbucketbot.utils;
|
||||||
|
|
||||||
import com.tsc.bitbucketbot.domain.entity.PullRequest;
|
import org.sadtech.bot.bitbucketbot.domain.entity.PullRequest;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user