mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-01-09 02:44:00 +00:00
Compare commits
8 Commits
abstracto-
...
abstracto-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4410928136 | ||
|
|
a756cbcf31 | ||
|
|
14d3e37177 | ||
|
|
244000bbe4 | ||
|
|
134f25955c | ||
|
|
ddb256cf75 | ||
|
|
08edcbdf8e | ||
|
|
fd9a446f9e |
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>assignable-roles</artifactId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>assignable-roles</artifactId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>assignable-roles-int</artifactId>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>entertainment</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>entertainment</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>experience-tracking</artifactId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>experience-tracking</artifactId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>link-embed</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ import java.util.regex.Pattern;
|
||||
@Slf4j
|
||||
public class MessageEmbedServiceBean implements MessageEmbedService {
|
||||
|
||||
private Pattern messageRegex = Pattern.compile("(?<whole>https://discord(?:app)?.com/channels/(?<server>\\d+)/(?<channel>\\d+)/(?<message>\\d+)(?:.*?))+");
|
||||
private final Pattern messageRegex = Pattern.compile("(?<whole>(?:https?://)?(?:\\w+\\.)?discord(?:app)?\\.com/channels/(?<server>\\d+)/(?<channel>\\d+)/(?<message>\\d+)(?:.*?))+");
|
||||
|
||||
public static final String MESSAGE_EMBED_TEMPLATE = "message_embed";
|
||||
public static final String REMOVAL_EMOTE = "removeEmbed";
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>link-embed</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>moderation</artifactId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>moderation</artifactId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>modmail</artifactId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>modmail</artifactId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto</groupId>
|
||||
<artifactId>abstracto-application</artifactId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>remind</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>remind</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>repost-detection</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>repost-detection</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>starboard</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@ public interface StarboardPostReactionRepository extends JpaRepository<Starboard
|
||||
|
||||
void deleteByStarboardPost(StarboardPost post);
|
||||
|
||||
long countByStarboardPost(StarboardPost post);
|
||||
|
||||
@Query(value = "SELECT r.reactor_user_in_server_id as userId, COUNT(*) AS starCount \n" +
|
||||
"FROM starboard_post_reaction r \n" +
|
||||
"INNER JOIN starboard_post p ON p.id = r.post_id\n" +
|
||||
|
||||
@@ -18,6 +18,8 @@ public interface StarboardPostRepository extends JpaRepository<StarboardPost, Lo
|
||||
|
||||
List<StarboardPost> findByServer_Id(Long serverId);
|
||||
|
||||
Long countByServer_Id(Long serverId);
|
||||
|
||||
@Query(value = "SELECT p.id, COUNT(*) AS starCount \n" +
|
||||
" FROM starboard_post p \n" +
|
||||
" INNER JOIN starboard_post_reaction r ON p.id = r.post_id\n" +
|
||||
@@ -30,6 +32,16 @@ public interface StarboardPostRepository extends JpaRepository<StarboardPost, Lo
|
||||
" LIMIT :count", nativeQuery = true)
|
||||
List<Long> getTopStarboardPostsForUser(Long serverId, Long userId, Integer count);
|
||||
|
||||
@Query(value = "SELECT p.id, COUNT(*) AS starCount \n" +
|
||||
" FROM starboard_post p \n" +
|
||||
" INNER JOIN starboard_post_reaction r ON p.id = r.post_id\n" +
|
||||
" WHERE p.server_id = :serverId\n" +
|
||||
" AND p.ignored = false\n" +
|
||||
" GROUP BY p.id \n" +
|
||||
" ORDER BY starCount DESC \n" +
|
||||
" LIMIT :count", nativeQuery = true)
|
||||
List<Long> getTopStarboardPostsForServer(Long serverId, Integer count);
|
||||
|
||||
@Query(value = "SELECT COUNT(*) AS starCount\n" +
|
||||
"FROM starboard_post_reaction r \n" +
|
||||
" INNER JOIN starboard_post p ON p.id = r.post_id \n" +
|
||||
|
||||
@@ -196,8 +196,8 @@ public class StarboardServiceBean implements StarboardService {
|
||||
allFutures.addAll(topStarReceiverFutures);
|
||||
return FutureUtils.toSingleFuture(allFutures).thenApply(aVoid -> {
|
||||
List<StarboardPost> starboardPosts = starboardPostManagementService.retrieveTopPosts(serverId, count);
|
||||
List<StarStatsPost> starStatsPosts = starboardPosts.stream().map(this::fromStarboardPost).collect(Collectors.toList());
|
||||
Integer postCount = starboardPostManagementService.getPostCount(serverId);
|
||||
List<StarStatsPost> starStatsPosts = starboardPosts.stream().map(this::fromStarboardPost).sorted(Comparator.comparingLong(StarStatsPost::getStarCount).reversed()).collect(Collectors.toList());
|
||||
Long postCount = starboardPostManagementService.getPostCount(serverId);
|
||||
Integer reactionCount = starboardPostReactorManagementService.getStarCount(serverId);
|
||||
List<String> emotes = new ArrayList<>();
|
||||
for (int i = 1; i < count + 1; i++) {
|
||||
@@ -224,7 +224,7 @@ public class StarboardServiceBean implements StarboardService {
|
||||
Long receivedStars = starboardPostManagementService.retrieveReceivedStarsOfUserInServer(member.getGuild().getIdLong(), member.getIdLong());
|
||||
Long givenStars = starboardPostManagementService.retrieveGivenStarsOfUserInServer(member.getGuild().getIdLong(), member.getIdLong());
|
||||
List<StarboardPost> topPosts = starboardPostManagementService.retrieveTopPostsForUserInServer(member.getGuild().getIdLong(), member.getIdLong(), count);
|
||||
List<StarStatsPost> starStatsPosts = topPosts.stream().map(this::fromStarboardPost).sorted(Comparator.comparingInt(StarStatsPost::getStarCount).reversed()).collect(Collectors.toList());
|
||||
List<StarStatsPost> starStatsPosts = topPosts.stream().map(this::fromStarboardPost).sorted(Comparator.comparingLong(StarStatsPost::getStarCount).reversed()).collect(Collectors.toList());
|
||||
List<String> emotes = new ArrayList<>();
|
||||
for (int i = 1; i < count + 1; i++) {
|
||||
emotes.add(getStarboardRankingEmote(member.getGuild().getIdLong(), i));
|
||||
@@ -246,7 +246,7 @@ public class StarboardServiceBean implements StarboardService {
|
||||
.serverId(starboardPost.getServer().getId())
|
||||
.channelId(channel.getId())
|
||||
.messageId(starboardPost.getPostMessageId())
|
||||
.starCount(starboardPost.getReactions().size())
|
||||
.starCount(starboardPostReactorManagementService.getReactorCountOfPost(starboardPost))
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -58,10 +58,8 @@ public class StarboardPostManagementServiceBean implements StarboardPostManageme
|
||||
|
||||
@Override
|
||||
public List<StarboardPost> retrieveTopPosts(Long serverId, Integer count) {
|
||||
List<StarboardPost> posts = retrieveAllPosts(serverId);
|
||||
posts.sort(Comparator.comparingInt(o -> o.getReactions().size()));
|
||||
Collections.reverse(posts);
|
||||
return posts.subList(0, Math.min(count, posts.size()));
|
||||
List<Long> topPostIds = repository.getTopStarboardPostsForServer(serverId, count);
|
||||
return repository.findAllById(topPostIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -86,8 +84,8 @@ public class StarboardPostManagementServiceBean implements StarboardPostManageme
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getPostCount(Long serverId) {
|
||||
return retrieveAllPosts(serverId).size();
|
||||
public Long getPostCount(Long serverId) {
|
||||
return repository.countByServer_Id(serverId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -65,4 +65,9 @@ public class StarboardPostReactorManagementServiceBean implements StarboardPostR
|
||||
return converter.convertToStarStatsUser(starReceivers, serverId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getReactorCountOfPost(StarboardPost starboardPost) {
|
||||
return repository.countByStarboardPost(starboardPost);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog ../dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext ../dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/pro ../dbchangelog-3.8.xsd" >
|
||||
<include file="starboard-tables/tables.xml" relativeToChangelogFile="true"/>
|
||||
</databaseChangeLog>
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog ../../dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext ../../dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/pro ../../dbchangelog-3.8.xsd" >
|
||||
<changeSet author="Sheldan" id="additional_starboard_post-index">
|
||||
<createIndex indexName="idx_starboard_author" tableName="starboard_post">
|
||||
<column name="author_user_in_server_id"/>
|
||||
</createIndex>
|
||||
</changeSet>
|
||||
|
||||
</databaseChangeLog>
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog ../../dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext ../../dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/pro ../../dbchangelog-3.8.xsd" >
|
||||
<changeSet author="Sheldan" id="additional_starboard_reaction-index">
|
||||
<createIndex indexName="idx_starboard_reaction_user" tableName="starboard_post_reaction">
|
||||
<column name="reactor_user_in_server_id"/>
|
||||
</createIndex>
|
||||
<createIndex indexName="idx_starboard_reaction_post" tableName="starboard_post_reaction">
|
||||
<column name="post_id"/>
|
||||
</createIndex>
|
||||
</changeSet>
|
||||
|
||||
</databaseChangeLog>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog ../../dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext ../../dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/pro ../../dbchangelog-3.8.xsd" >
|
||||
<include file="starboard_post.xml" relativeToChangelogFile="true"/>
|
||||
<include file="starboard_post_reaction.xml" relativeToChangelogFile="true"/>
|
||||
</databaseChangeLog>
|
||||
@@ -7,4 +7,5 @@
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/pro dbchangelog-3.8.xsd" >
|
||||
<include file="1.0-starboard/collection.xml" relativeToChangelogFile="true"/>
|
||||
<include file="1.2.3-starboard/collection.xml" relativeToChangelogFile="true"/>
|
||||
</databaseChangeLog>
|
||||
@@ -298,7 +298,7 @@ public class StarboardServiceBeanTest {
|
||||
List<CompletableFuture<StarStatsUser>> topGiver = Arrays.asList(statsUser, statsUser2);
|
||||
when(starboardPostReactorManagementService.retrieveTopStarGiver(SERVER_ID, limit)).thenReturn(topGiver);
|
||||
when(starboardPostReactorManagementService.retrieveTopStarReceiver(SERVER_ID, limit)).thenReturn(topGiver);
|
||||
when(starboardPostManagementService.getPostCount(SERVER_ID)).thenReturn(50);
|
||||
when(starboardPostManagementService.getPostCount(SERVER_ID)).thenReturn(50L);
|
||||
when(starboardPostReactorManagementService.getStarCount(SERVER_ID)).thenReturn(500);
|
||||
when(emoteService.getUsableEmoteOrDefault(SERVER_ID, "starboardBadge1")).thenReturn("1");
|
||||
when(emoteService.getUsableEmoteOrDefault(SERVER_ID, "starboardBadge2")).thenReturn("2");
|
||||
|
||||
@@ -198,7 +198,7 @@ public class StarboardPostManagementServiceBeanTest {
|
||||
StarboardPost starboardPost2 = Mockito.mock(StarboardPost.class);
|
||||
List<StarboardPost> posts = Arrays.asList(starboardPost1, starboardPost2);
|
||||
when(repository.findByServer_Id(SERVER_ID)).thenReturn(posts);
|
||||
Integer retrievedPostCount = testUnit.getPostCount(SERVER_ID);
|
||||
Long retrievedPostCount = testUnit.getPostCount(SERVER_ID);
|
||||
Assert.assertEquals(posts.size(), retrievedPostCount.intValue());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>starboard</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -15,5 +15,5 @@ public class GuildStarStatsModel {
|
||||
private List<StarStatsUser> starGiver;
|
||||
private Integer totalStars;
|
||||
private List<String> badgeEmotes;
|
||||
private Integer starredMessages;
|
||||
private Long starredMessages;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ public class StarStatsPost {
|
||||
private Long serverId;
|
||||
private Long channelId;
|
||||
private Long messageId;
|
||||
private Integer starCount;
|
||||
private Long starCount;
|
||||
|
||||
public String getMessageUrl() {
|
||||
return MessageUtils.buildMessageUrl(serverId ,channelId, messageId);
|
||||
|
||||
@@ -17,7 +17,7 @@ public interface StarboardPostManagementService {
|
||||
Long retrieveGivenStarsOfUserInServer(Long serverId, Long userId);
|
||||
Long retrieveReceivedStarsOfUserInServer(Long serverId, Long userId);
|
||||
List<StarboardPost> retrieveAllPosts(Long serverId);
|
||||
Integer getPostCount(Long serverId);
|
||||
Long getPostCount(Long serverId);
|
||||
Optional<StarboardPost> findByMessageId(Long messageId);
|
||||
Optional<StarboardPost> findByStarboardPostId(Long postId);
|
||||
Optional<StarboardPost> findByStarboardPostMessageId(Long postId);
|
||||
|
||||
@@ -15,4 +15,5 @@ public interface StarboardPostReactorManagementService {
|
||||
Integer getStarCount(Long serverId);
|
||||
List<CompletableFuture<StarStatsUser>> retrieveTopStarGiver(Long serverId, Integer count);
|
||||
List<CompletableFuture<StarStatsUser>> retrieveTopStarReceiver(Long serverId, Integer count);
|
||||
Long getReactorCountOfPost(StarboardPost starboardPost);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>statistic</artifactId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>statistic</artifactId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>suggestion</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>suggestion</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>utility</artifactId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>utility</artifactId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto</groupId>
|
||||
<artifactId>abstracto-application</artifactId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -9,7 +9,6 @@ import net.dv8tion.jda.api.requests.restaction.pagination.ReactionPaginationActi
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.awt.*;
|
||||
import java.time.Instant;
|
||||
@@ -155,42 +154,29 @@ public class CacheEntityServiceBean implements CacheEntityService {
|
||||
@Override
|
||||
public CompletableFuture<CachedReactions> getCachedReactionFromReaction(MessageReaction reaction) {
|
||||
CompletableFuture<CachedReactions> future = new CompletableFuture<>();
|
||||
ReactionPaginationAction users = reaction.retrieveUsers();
|
||||
ReactionPaginationAction users = reaction.retrieveUsers().cache(false);
|
||||
CachedReactions.CachedReactionsBuilder builder = CachedReactions.builder();
|
||||
|
||||
List<ServerUser> aUsers = new ArrayList<>();
|
||||
users.forEachAsync(user -> {
|
||||
log.trace("Loading user {} for reaction.", user.getIdLong());
|
||||
concreteSelf.loadUser(reaction, aUsers, user);
|
||||
return false;
|
||||
}).thenAccept(o -> {
|
||||
log.trace("Users have been loaded. Completing future.");
|
||||
if(reaction.getGuild() != null) {
|
||||
aUsers.add(ServerUser.builder().userId(user.getIdLong()).serverId(reaction.getGuild().getIdLong()).build());
|
||||
}
|
||||
return true;
|
||||
}).whenComplete((o, throwable) -> {
|
||||
log.trace("{} Users have been loaded. Completing future.", aUsers.size());
|
||||
if(throwable != null) {
|
||||
log.error("Reaction user retrieval failed. Completing with what we have.", throwable);
|
||||
}
|
||||
builder.users(aUsers);
|
||||
builder.self(reaction.isSelf());
|
||||
builder.emote(getCachedEmoteFromEmote(reaction.getReactionEmote(), reaction.getGuild()));
|
||||
future.complete(builder.build());
|
||||
})
|
||||
.exceptionally(throwable -> {
|
||||
log.error("Failed to load reaction users.", throwable);
|
||||
return null;
|
||||
});
|
||||
if(users.isEmpty()) {
|
||||
log.trace("Reaction had no users. Completing future anyway.");
|
||||
builder.users(aUsers);
|
||||
builder.self(reaction.isSelf());
|
||||
builder.emote(getCachedEmoteFromEmote(reaction.getReactionEmote(), reaction.getGuild()));
|
||||
future.complete(builder.build());
|
||||
}
|
||||
return future;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void loadUser(MessageReaction reaction, List<ServerUser> aUsers, User user) {
|
||||
if(reaction.getGuild() != null) {
|
||||
aUsers.add(ServerUser.builder().userId(user.getIdLong()).serverId(reaction.getGuild().getIdLong()).build());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<CachedMessage> buildCachedMessageFromMessage(Message message) {
|
||||
CompletableFuture<CachedMessage> future = new CompletableFuture<>();
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>core</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>core</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto</groupId>
|
||||
<artifactId>abstracto-application</artifactId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto</groupId>
|
||||
<artifactId>abstracto-application</artifactId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>coverage</artifactId>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-application</artifactId>
|
||||
<groupId>dev.sheldan.abstracto</groupId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto</groupId>
|
||||
<artifactId>abstracto-application</artifactId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
<groupId>dev.sheldan.abstracto</groupId>
|
||||
<artifactId>abstracto-application</artifactId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
@@ -35,7 +35,7 @@
|
||||
<scm>
|
||||
<url>https://maven.pkg.github.com/Sheldan/abstracto</url>
|
||||
<developerConnection>scm:git:git@github.com:Sheldan/abstracto.git</developerConnection>
|
||||
<tag>abstracto-application-1.2.2</tag>
|
||||
<tag>abstracto-application-1.2.4</tag>
|
||||
</scm>
|
||||
|
||||
<repositories>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto</groupId>
|
||||
<artifactId>abstracto-application</artifactId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.scheduling</groupId>
|
||||
<artifactId>scheduling</artifactId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.scheduling</groupId>
|
||||
<artifactId>scheduling</artifactId>
|
||||
<version>1.2.2</version>
|
||||
<version>1.2.4</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
Reference in New Issue
Block a user