-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix : redis 랭킹 버그 수정 #150
fix : redis 랭킹 버그 수정 #150
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
코멘트 몇개 남겼습니다!
src/main/kotlin/io/csbroker/apiserver/repository/common/RedisRepository.kt
Outdated
Show resolved
Hide resolved
val rankKey = redisTemplate.opsForZSet().reverseRangeByScore(RANKING, score, score, 0, 1)?.firstOrNull() | ||
|
||
if (rankKey != null) { | ||
rank = redisTemplate.opsForZSet().reverseRank(RANKING, rankKey)?.plus(1) | ||
val rank = rankKey?.let { | ||
redisTemplate.opsForZSet().reverseRank(RANKING, rankKey)?.plus(1) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val rankKey = redisTemplate.opsForZSet().reverseRangeByScore(RANKING, score, score, 0, 1)?.firstOrNull() | |
if (rankKey != null) { | |
rank = redisTemplate.opsForZSet().reverseRank(RANKING, rankKey)?.plus(1) | |
val rank = rankKey?.let { | |
redisTemplate.opsForZSet().reverseRank(RANKING, rankKey)?.plus(1) | |
} | |
val rankKey = redisTemplate.opsForZSet().reverseRangeByScore(RANKING, score, score, 0, 1)?.first() | |
val rank = redisTemplate.opsForZSet().reverseRank(RANKING, rankKey!!)?.plus(1) |
위에 score가 받아져왔다는 건 무조건 하나 이상의 점수가 레디스에 있다는 거니까 !!를 통해 무조건 존재한다는 걸 코드에 내포하는 건 어떨까요?
�위와 같이 정리하면 코드가 더 깔끔해질 것 같아요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ekzm8523 이건 사람마다 의견이 다를 수 있을 것 같아요. 저는 후자인듯?
rank의 score과 key가 확실하게 존재한다는 것을 의미하게 코드 짜기 vs ?
을 사용하여 null 안정성을 확보하면서 코드짜기.
어떻게 생각하시나요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
마지막에 변경된 rankKey?.let도 적절해보입니다~ 이렇게 가시져
src/main/kotlin/io/csbroker/apiserver/repository/common/RedisRepository.kt
Outdated
Show resolved
Hide resolved
src/test/kotlin/io/csbroker/apiserver/repository/common/RedisRepositoryTest.kt
Show resolved
Hide resolved
Quality Gate passedKudos, no new issues were introduced! 0 New issues |
Issue Number
close: # N/A
작업 내역
변경사항
작업 유형
PR 특이 사항