Исправление рейтинговой системы
This commit is contained in:
parent
0bb74203ea
commit
dad18d396a
@ -16,31 +16,26 @@
|
||||
<dependency>
|
||||
<groupId>org.sadtech.bot.bitbucketbot</groupId>
|
||||
<artifactId>bot-core</artifactId>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.sadtech.bot.bitbucketbot</groupId>
|
||||
<artifactId>bot-rest</artifactId>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.sadtech.bot.bitbucketbot</groupId>
|
||||
<artifactId>telegram-bot</artifactId>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.sadtech.bot.bitbucketbot</groupId>
|
||||
<artifactId>teamcity-core</artifactId>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.sadtech.bot.bitbucketbot</groupId>
|
||||
<artifactId>bitbucket-sdk</artifactId>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
@ -32,7 +32,8 @@ public class RatingScheduler {
|
||||
ratingService.ratingRecalculation();
|
||||
}
|
||||
|
||||
@Scheduled(cron = "0 20 8 * * MON-FRI")
|
||||
// @Scheduled(cron = "0 20 8 * * MON-FRI")
|
||||
@Scheduled(cron = "0 */1 * * * *")
|
||||
private void goodMorningRating() {
|
||||
List<Person> allRegister = personService.getAllRegister();
|
||||
for (Person person : allRegister) {
|
||||
|
@ -2,8 +2,8 @@ package org.sadtech.bot.vcs.core.domain.entity;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import lombok.Setter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
@ -35,7 +35,7 @@ public class RatingList implements Comparable<RatingList> {
|
||||
private Integer number;
|
||||
|
||||
@Override
|
||||
public int compareTo(@NotNull RatingList ratingList) {
|
||||
public int compareTo(@NonNull RatingList ratingList) {
|
||||
return Integer.compare(ratingList.getPoints(), points);
|
||||
}
|
||||
|
||||
|
@ -62,10 +62,9 @@ public class GoodMorningNotify extends Notify {
|
||||
messageNeedWork -> message.append(Smile.TWO_BR)
|
||||
.append(Smile.DANGEROUS).append(" Требуется доработать ").append(pullRequestsNeedWork.size()).append(" ПР:").append(Smile.BR)
|
||||
.append(messageNeedWork)
|
||||
.append(Smile.BR)
|
||||
);
|
||||
message
|
||||
.append(Smile.BR).append("Удачного дня ").append(Smile.FLOWER)
|
||||
.append(Smile.TWO_BR).append("Удачного дня ").append(Smile.FLOWER)
|
||||
.append(Smile.HR)
|
||||
.append("_Version ").append(version).append(" | Developer @uPagge_");
|
||||
return message.toString();
|
||||
|
@ -14,7 +14,7 @@ import java.util.stream.Stream;
|
||||
public abstract class Notify {
|
||||
|
||||
public static final Set<Character> FORBIDDEN_SYMBOLS = Stream.of(
|
||||
'\\', '+', '`', '[', ']', '\"', '~', '*', '#', '=', '-', '_', '>', '<', '!'
|
||||
'\\', '+', '`', '[', ']', '\"', '~', '*', '#', '=', '_', '>', '<'
|
||||
).collect(Collectors.toSet());
|
||||
|
||||
protected EntityType entityType;
|
||||
|
@ -24,7 +24,7 @@ public class SimpleTextNotify extends Notify {
|
||||
|
||||
@Override
|
||||
public String generateMessage() {
|
||||
return escapeMarkdown(message);
|
||||
return message;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,8 +4,6 @@ import org.sadtech.basic.database.repository.manager.AbstractSimpleManagerReposi
|
||||
import org.sadtech.bot.vcs.core.domain.entity.RatingList;
|
||||
import org.sadtech.bot.vcs.core.repository.RatingListRepository;
|
||||
import org.sadtech.bot.vcs.core.repository.jpa.RatingListJpaRepository;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
@ -33,21 +31,17 @@ public class RatingListRepositoryImpl extends AbstractSimpleManagerRepository<Ra
|
||||
|
||||
@Override
|
||||
public List<RatingList> findFirstThree() {
|
||||
return jpaRepository.findAll(
|
||||
PageRequest.of(0, 3, Sort.by(Sort.Direction.ASC, "number"))
|
||||
).getContent();
|
||||
return jpaRepository.findTop3ByPointsGreaterThanOrderByNumberAsc(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RatingList> findLastThree() {
|
||||
return jpaRepository.findAll(
|
||||
PageRequest.of(0, 3, Sort.by(Sort.Direction.DESC, "number"))
|
||||
).getContent();
|
||||
return jpaRepository.findTop3ByPointsGreaterThanOrderByNumberDesc(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long count() {
|
||||
return jpaRepository.count();
|
||||
return jpaRepository.countByNumberGreaterThan(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,8 @@ package org.sadtech.bot.vcs.core.repository.jpa;
|
||||
import org.sadtech.bot.vcs.core.domain.entity.RatingList;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* // TODO: 01.10.2020 Добавить описание.
|
||||
*
|
||||
@ -10,4 +12,10 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
||||
*/
|
||||
public interface RatingListJpaRepository extends JpaRepository<RatingList, String> {
|
||||
|
||||
List<RatingList> findTop3ByPointsGreaterThanOrderByNumberAsc(Integer points);
|
||||
|
||||
List<RatingList> findTop3ByPointsGreaterThanOrderByNumberDesc(Integer points);
|
||||
|
||||
Long countByNumberGreaterThan(Integer points);
|
||||
|
||||
}
|
||||
|
@ -140,20 +140,22 @@ public class PullRequestsServiceImpl extends AbstractSimpleManagerService<PullRe
|
||||
!oldPullRequest.getBitbucketVersion().equals(pullRequest.getBitbucketVersion())
|
||||
) {
|
||||
oldPullRequest.setBitbucketVersion(pullRequest.getBitbucketVersion());
|
||||
notifyService.send(
|
||||
UpdatePrNotify.builder()
|
||||
.author(oldPullRequest.getAuthorLogin())
|
||||
.name(pullRequest.getTitle())
|
||||
.recipients(
|
||||
pullRequest.getReviewers().stream()
|
||||
.map(Reviewer::getPersonLogin)
|
||||
.collect(Collectors.toSet())
|
||||
)
|
||||
.url(oldPullRequest.getUrl())
|
||||
.projectKey(oldPullRequest.getProjectKey())
|
||||
.repositorySlug(oldPullRequest.getRepositorySlug())
|
||||
.build()
|
||||
);
|
||||
if (PullRequestStatus.OPEN.equals(pullRequest.getStatus())) {
|
||||
notifyService.send(
|
||||
UpdatePrNotify.builder()
|
||||
.author(oldPullRequest.getAuthorLogin())
|
||||
.name(pullRequest.getTitle())
|
||||
.recipients(
|
||||
pullRequest.getReviewers().stream()
|
||||
.map(Reviewer::getPersonLogin)
|
||||
.collect(Collectors.toSet())
|
||||
)
|
||||
.url(oldPullRequest.getUrl())
|
||||
.projectKey(oldPullRequest.getProjectKey())
|
||||
.repositorySlug(oldPullRequest.getRepositorySlug())
|
||||
.build()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ public class RatingServiceImpl implements RatingService {
|
||||
public String getRatingTop(@NonNull String login) {
|
||||
final RatingList personRating = ratingListRepository.getByLogin(login)
|
||||
.orElseThrow(() -> new NotFoundException("Пользователь не найден"));
|
||||
final Integer numberRatingList = personRating.getNumber();
|
||||
|
||||
final long countPerson = ratingListRepository.count();
|
||||
final String threeMessage = ratingListRepository.findFirstThree().stream()
|
||||
.map(this::createString)
|
||||
@ -99,16 +99,24 @@ public class RatingServiceImpl implements RatingService {
|
||||
.limit(countPerson - 3 < 0 ? 0 : countPerson - 3)
|
||||
.map(this::createString)
|
||||
.collect(Collectors.joining("\n"));
|
||||
String message = "Рейтинговая таблица | Всего участников: " + countPerson + "\n\n" + threeMessage;
|
||||
|
||||
if (numberRatingList <= 2) {
|
||||
if (countPerson > 3) {
|
||||
message += "\n... ... ...\n";
|
||||
}
|
||||
} else if (numberRatingList > 3 && numberRatingList <= (countPerson - 3)) {
|
||||
message += "\n... ... ...\n" + personRating.getNumber() + ": " + personRating.getLogin() + "\n... ... ...\n";
|
||||
String message;
|
||||
|
||||
if (personRating.getPoints() == 0) {
|
||||
message = Smile.SADLY + " У вас не обнаружена активность в битбакете, поэтому вы не учавствуйте в рейтинге" +
|
||||
"\n\n" + Smile.TOP + " Рейтинговая таблица " + Smile.TOP + Smile.HR + threeMessage + "\n... ... ... ... ...\n";
|
||||
} else {
|
||||
message += "\n... ... ...\n";
|
||||
message = Smile.TOP + " Рейтинговая таблица " + Smile.TOP + Smile.HR + threeMessage;
|
||||
final Integer numberRatingList = personRating.getNumber();
|
||||
if (numberRatingList <= 2) {
|
||||
if (countPerson > 3) {
|
||||
message += "\n... ... ... ... ...\n";
|
||||
}
|
||||
} else if (numberRatingList > 3 && numberRatingList <= (countPerson - 3)) {
|
||||
message += "\n... ... ... ... ...\n" + personRating.getNumber() + ": " + personRating.getLogin() + "\n... ... ... ... ...\n";
|
||||
} else {
|
||||
message += "\n... ... ... ... ...\n";
|
||||
}
|
||||
}
|
||||
message += lastMessage;
|
||||
return message;
|
||||
|
@ -39,7 +39,9 @@ public enum Smile {
|
||||
FAILURE("❌"),
|
||||
SUCCESS("✅"),
|
||||
BUILD("♻️"),
|
||||
SMART("\uD83E\uDDE0");
|
||||
SMART("\uD83E\uDDE0"),
|
||||
SADLY("\uD83D\uDE14"),
|
||||
TOP("\uD83D\uDD1D");
|
||||
|
||||
@Getter
|
||||
private final String value;
|
||||
|
@ -17,7 +17,6 @@
|
||||
<dependency>
|
||||
<groupId>org.sadtech.bot.bitbucketbot</groupId>
|
||||
<artifactId>bot-core</artifactId>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -32,5 +31,4 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
105
pom.xml
105
pom.xml
@ -25,91 +25,102 @@
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
|
||||
<vcs.core>2.1.0-SNAPSHOT</vcs.core>
|
||||
<org.sadtech.bot-core.version>2.1.0-SNAPSHOT</org.sadtech.bot-core.version>
|
||||
<org.sadtech.bot.teamcity-core.version>2.1.0-SNAPSHOT</org.sadtech.bot.teamcity-core.version>
|
||||
<org.sadtech.bot.teamcity-sdk.version>2.1.0-SNAPSHOT</org.sadtech.bot.teamcity-sdk.version>
|
||||
<org.sadtech.bot.bitbucket-sdk.version>2.1.0-SNAPSHOT</org.sadtech.bot.bitbucket-sdk.version>
|
||||
<org.sadtech.bot.rest.version>2.1.0-SNAPSHOT</org.sadtech.bot.rest.version>
|
||||
<org.sadtech.bot.telegram.version>2.1.0-SNAPSHOT</org.sadtech.bot.telegram.version>
|
||||
<org.sadtech.telegram.bot-core.version>0.0.1-DEVELOPER</org.sadtech.telegram.bot-core.version>
|
||||
|
||||
<sadtech.project.database>0.1.0-SNAPSHOT</sadtech.project.database>
|
||||
<sadtech.project.filter.criteria>0.1.0-SNAPSHOT</sadtech.project.filter.criteria>
|
||||
<sadtech.project.database.version>0.1.0-SNAPSHOT</sadtech.project.database.version>
|
||||
<sadtech.project.filter.criteria.version>0.1.0-SNAPSHOT</sadtech.project.filter.criteria.version>
|
||||
|
||||
<hibernate.jpamodelgen>6.0.0.Alpha5</hibernate.jpamodelgen>
|
||||
<liquibase.core>3.8.5</liquibase.core>
|
||||
<postgresql>42.2.9</postgresql>
|
||||
<javax.persistance>2.2</javax.persistance>
|
||||
<javax.persistance.version>2.2</javax.persistance.version>
|
||||
|
||||
<springboot.config.processor>2.3.1.RELEASE</springboot.config.processor>
|
||||
|
||||
<google.guava>28.2-jre</google.guava>
|
||||
<okhttp3>4.9.0</okhttp3>
|
||||
<hibernate.jpa-modelgen.version>6.0.0.Alpha5</hibernate.jpa-modelgen.version>
|
||||
<google.guava.version>28.2-jre</google.guava.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.sadtech.bot.bitbucketbot</groupId>
|
||||
<artifactId>bot-rest</artifactId>
|
||||
<version>${org.sadtech.bot.rest.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.sadtech.bot.bitbucketbot</groupId>
|
||||
<artifactId>telegram-bot</artifactId>
|
||||
<version>${org.sadtech.bot.telegram.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.sadtech.bot.bitbucketbot</groupId>
|
||||
<artifactId>bot-core</artifactId>
|
||||
<version>${vcs.core}</version>
|
||||
<version>${org.sadtech.bot-core.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.sadtech.bot.bitbucketbot</groupId>
|
||||
<artifactId>teamcity-sdk</artifactId>
|
||||
<version>${org.sadtech.bot.teamcity-sdk.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.sadtech.bot.bitbucketbot</groupId>
|
||||
<artifactId>bitbucket-sdk</artifactId>
|
||||
<version>${org.sadtech.bot.bitbucket-sdk.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.sadtech.bot.bitbucketbot</groupId>
|
||||
<artifactId>teamcity-core</artifactId>
|
||||
<version>${org.sadtech.bot.teamcity-core.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.sadtech.basic.filter</groupId>
|
||||
<artifactId>criteria-filter</artifactId>
|
||||
<version>${sadtech.project.filter.criteria}</version>
|
||||
<version>${sadtech.project.filter.criteria.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.sadtech.basic</groupId>
|
||||
<artifactId>project-database</artifactId>
|
||||
<version>${sadtech.project.database}</version>
|
||||
<version>${sadtech.project.database.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.sadtech.telegram</groupId>
|
||||
<artifactId>telegram-bot</artifactId>
|
||||
<version>${org.sadtech.telegram.bot-core.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.hibernate.orm</groupId>
|
||||
<artifactId>hibernate-jpamodelgen</artifactId>
|
||||
<version>${hibernate.jpamodelgen}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<version>${springboot.config.processor}</version>
|
||||
<version>${hibernate.jpa-modelgen.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>${google.guava}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
<version>2.3.3.RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<version>2.3.3.RELEASE</version>
|
||||
<scope>runtime</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
<version>2.3.3.RELEASE</version>
|
||||
<version>${google.guava.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.liquibase</groupId>
|
||||
<artifactId>liquibase-core</artifactId>
|
||||
<version>${liquibase.core}</version>
|
||||
<version>${liquibase.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<version>${postgresql}</version>
|
||||
<version>${postgresql.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -121,7 +132,7 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<version>2.3.3.RELEASE</version>
|
||||
<version>2.2.4.RELEASE</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
@ -133,7 +144,7 @@
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>${okhttp3}</version>
|
||||
<version>${okhttp3.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -145,7 +156,7 @@
|
||||
<dependency>
|
||||
<groupId>javax.persistence</groupId>
|
||||
<artifactId>javax.persistence-api</artifactId>
|
||||
<version>${javax.persistance}</version>
|
||||
<version>${javax.persistance.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
@ -21,7 +21,7 @@
|
||||
<dependency>
|
||||
<groupId>org.sadtech.bot.bitbucketbot</groupId>
|
||||
<artifactId>teamcity-sdk</artifactId>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<version>${org.sadtech.bot.teamcity-sdk.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
@ -29,11 +29,6 @@
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>javax.persistence</groupId>-->
|
||||
<!-- <artifactId>javax.persistence-api</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
|
@ -18,11 +18,9 @@
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
<version>2.11.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
@ -12,23 +12,19 @@
|
||||
<artifactId>telegram-bot</artifactId>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.sadtech.bot.bitbucketbot</groupId>
|
||||
<artifactId>bot-core</artifactId>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.sadtech.bot.bitbucketbot</groupId>
|
||||
<artifactId>teamcity-core</artifactId>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.sadtech.telegram</groupId>
|
||||
<artifactId>telegram-bot</artifactId>
|
||||
<version>0.0.1-DEVELOPER</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
@ -30,4 +30,5 @@ public class RatingTopProcessing implements ProcessingData<Message> {
|
||||
.message(ratingService.getRatingTop(person.getLogin()))
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user