mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-01-02 07:44:25 +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" +
|
||||
"FROM starboard_post_reaction r \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)
|
||||
Integer getReactionCountByServer(Long serverId);
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ public interface StarboardPostRepository extends JpaRepository<StarboardPost, Lo
|
||||
|
||||
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" +
|
||||
" FROM starboard_post p \n" +
|
||||
|
||||
@@ -218,7 +218,11 @@ 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).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);
|
||||
Integer reactionCount = starboardPostReactorManagementService.getStarCount(serverId);
|
||||
List<String> emotes = new ArrayList<>();
|
||||
|
||||
@@ -85,7 +85,7 @@ public class StarboardPostManagementServiceBean implements StarboardPostManageme
|
||||
|
||||
@Override
|
||||
public Long getPostCount(Long serverId) {
|
||||
return repository.countByServer_Id(serverId);
|
||||
return repository.countByServer_IdAndIgnoredIsFalse(serverId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -206,7 +206,7 @@ public class StarboardPostManagementServiceBeanTest {
|
||||
@Test
|
||||
public void testRetrievePostCount() {
|
||||
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);
|
||||
Assert.assertEquals(expectedCount, retrievedPostCount);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user