mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-14 19:56:29 +00:00
[AB-12] fixing not ignoring ignored starboard posts in starstats
fixes #12
This commit is contained in:
@@ -30,7 +30,8 @@ public interface StarboardPostReactionRepository extends JpaRepository<Starboard
|
|||||||
@Query(value = "SELECT COUNT(*) \n" +
|
@Query(value = "SELECT COUNT(*) \n" +
|
||||||
"FROM starboard_post_reaction r \n" +
|
"FROM starboard_post_reaction r \n" +
|
||||||
"INNER JOIN starboard_post p ON p.id = r.post_id\n" +
|
"INNER JOIN starboard_post p ON p.id = r.post_id\n" +
|
||||||
"WHERE p.server_id = :serverId\n"
|
"WHERE p.server_id = :serverId\n" +
|
||||||
|
"AND p.ignored = false"
|
||||||
, nativeQuery = true)
|
, nativeQuery = true)
|
||||||
Integer getReactionCountByServer(Long serverId);
|
Integer getReactionCountByServer(Long serverId);
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public interface StarboardPostRepository extends JpaRepository<StarboardPost, Lo
|
|||||||
|
|
||||||
List<StarboardPost> findByServer_Id(Long serverId);
|
List<StarboardPost> findByServer_Id(Long serverId);
|
||||||
|
|
||||||
Long countByServer_Id(Long serverId);
|
Long countByServer_IdAndIgnoredIsFalse(Long serverId);
|
||||||
|
|
||||||
@Query(value = "SELECT p.id, COUNT(*) AS starCount \n" +
|
@Query(value = "SELECT p.id, COUNT(*) AS starCount \n" +
|
||||||
" FROM starboard_post p \n" +
|
" FROM starboard_post p \n" +
|
||||||
|
|||||||
@@ -218,7 +218,11 @@ public class StarboardServiceBean implements StarboardService {
|
|||||||
allFutures.addAll(topStarReceiverFutures);
|
allFutures.addAll(topStarReceiverFutures);
|
||||||
return FutureUtils.toSingleFuture(allFutures).thenApply(aVoid -> {
|
return FutureUtils.toSingleFuture(allFutures).thenApply(aVoid -> {
|
||||||
List<StarboardPost> starboardPosts = starboardPostManagementService.retrieveTopPosts(serverId, count);
|
List<StarboardPost> starboardPosts = starboardPostManagementService.retrieveTopPosts(serverId, count);
|
||||||
List<StarStatsPost> starStatsPosts = starboardPosts.stream().map(this::fromStarboardPost).sorted(Comparator.comparingLong(StarStatsPost::getStarCount).reversed()).collect(Collectors.toList());
|
List<StarStatsPost> starStatsPosts = starboardPosts
|
||||||
|
.stream()
|
||||||
|
.map(this::fromStarboardPost)
|
||||||
|
.sorted(Comparator.comparingLong(StarStatsPost::getStarCount).reversed())
|
||||||
|
.collect(Collectors.toList());
|
||||||
Long postCount = starboardPostManagementService.getPostCount(serverId);
|
Long postCount = starboardPostManagementService.getPostCount(serverId);
|
||||||
Integer reactionCount = starboardPostReactorManagementService.getStarCount(serverId);
|
Integer reactionCount = starboardPostReactorManagementService.getStarCount(serverId);
|
||||||
List<String> emotes = new ArrayList<>();
|
List<String> emotes = new ArrayList<>();
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ public class StarboardPostManagementServiceBean implements StarboardPostManageme
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long getPostCount(Long serverId) {
|
public Long getPostCount(Long serverId) {
|
||||||
return repository.countByServer_Id(serverId);
|
return repository.countByServer_IdAndIgnoredIsFalse(serverId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ public class StarboardPostManagementServiceBeanTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testRetrievePostCount() {
|
public void testRetrievePostCount() {
|
||||||
Long expectedCount = 2L;
|
Long expectedCount = 2L;
|
||||||
when(repository.countByServer_Id(SERVER_ID)).thenReturn(expectedCount);
|
when(repository.countByServer_IdAndIgnoredIsFalse(SERVER_ID)).thenReturn(expectedCount);
|
||||||
Long retrievedPostCount = testUnit.getPostCount(SERVER_ID);
|
Long retrievedPostCount = testUnit.getPostCount(SERVER_ID);
|
||||||
Assert.assertEquals(expectedCount, retrievedPostCount);
|
Assert.assertEquals(expectedCount, retrievedPostCount);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user