Skip to content

Commit

Permalink
🔧 Fix getFeedsThatUserComments to return Only 10 Feeds
Browse files Browse the repository at this point in the history
  • Loading branch information
alpakar02 committed Jan 25, 2025
1 parent 0dc187d commit 3701a7d
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,14 @@ class FeedService(
feedId: Long,
): List<FeedEntity> {
val comments: List<CommentEntity> = commentService.getCommentsByUser(id)
return comments
.map { it.feed }
.filter { it.id!! < feedId }
.distinctBy { it.id }
.sortedByDescending { it.id }
val feeds: List<FeedEntity> =
comments
.map { it.feed }
.filter { it.id!! < feedId }
.distinctBy { it.id }
.sortedByDescending { it.id }
if (feeds.size < 10) return feeds
return feeds.subList(0, 10)
}

@Transactional
Expand Down

0 comments on commit 3701a7d

Please sign in to comment.