Skip to content

Commit

Permalink
Merge pull request #40 from molohala/Feature/ranking
Browse files Browse the repository at this point in the history
feat :: add isBlockedUser field
  • Loading branch information
jombidev authored Jul 20, 2024
2 parents deb4e3c + 41f6288 commit 3ce4e3e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class RankServiceImpl(
private fun getRankForKey(key: String): RankingTimedListRes {
val zSet = redisTemplate.opsForZSet()
val member = memberSessionHolder.current()
val blocks = blockRepository.findByUserId(member.id!!)
val blocks = blockRepository.findByUserId(member.id!!).associate { it.blockedUserId to Unit /* inspired by java's internal hash set implementation */ } //.map { it.blockedUserId }.toSet()

val lastNano = 2L * 60L * 60L * 1_000L * 1_000_000L - redisTemplate.getExpire(key, TimeUnit.NANOSECONDS)

Expand All @@ -66,10 +66,7 @@ class RankServiceImpl(
keepCount++
}
prevScore = score
RankingRes(value.memberId, value.name, value.socialId, rank, score)
}
.filter { res ->
blocks.firstOrNull { it.blockedUserId == res.memberId } == null
RankingRes(value.memberId, value.name, value.socialId, rank, blocks.contains(value.memberId), score)
}

return RankingTimedListRes(LocalDateTime.now().minusNanos(lastNano), map)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ data class RankingRes(
val memberName: String,
val socialId: String,
val rank: Int,
val isBlockedUser: Boolean,
val count: Long,
)
)

0 comments on commit 3ce4e3e

Please sign in to comment.