Skip to content

Commit

Permalink
Fix: 랭킹이 10등 이상으로 벗어나지 않도록 수정 (#81)
Browse files Browse the repository at this point in the history
* Feat: 랭킹 배지 조회 기능 구현

* Fix: 랭킹 조회 시, 각 커뮤니티의 랭킹도 보이도록 수정

* Fix: 랭킹이 10등 이상으로 벗어나지 않도록 수정
  • Loading branch information
emes-g authored Aug 12, 2024
1 parent a098aa1 commit ed2efc0
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/store/itpick/backend/util/Redis.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public void saveDay() {

for (int i = 0; i < realTimeKeyList.size(); i++) {
int score = 10;
redisTemplate.delete(dayKeyList.get(i)); // 기존 키 삭제
for (Object realTimeKeyword : Objects.requireNonNull(zSetOperations.reverseRange(realTimeKeyList.get(i), 0, 9))) {
zSetOperations.add(dayKeyList.get(i), realTimeKeyword, score--);
}
Expand All @@ -91,6 +92,7 @@ public void saveWeek() {
for (List<String> dayKeyList : dayKeyListOfPreviousWeek) { // 지난주 월요일부터 일요일까지, 각 커뮤니티의 키 리스트
for (int i = 0; i < dayKeyList.size(); i++) { // naver, nate, zum에 대하여
int score = 10;
redisTemplate.delete(weekKeyList.get(i)); // 기존 키 삭제
for (Object dayKeyword : Objects.requireNonNull(zSetOperations.reverseRange(dayKeyList.get(i), 0, 9))) {
if (!Boolean.TRUE.equals(zSetOperations.addIfAbsent(weekKeyList.get(i), dayKeyword, score))) {
zSetOperations.add(weekKeyList.get(i), dayKeyword, score + zSetOperations.score(weekKeyList.get(i), dayKeyword));
Expand Down

0 comments on commit ed2efc0

Please sign in to comment.