From 47193d318dab0311a88b0416ead0931cc02d52ef Mon Sep 17 00:00:00 2001 From: Govind Balaji S Date: Sun, 16 Oct 2022 13:09:11 +0530 Subject: [PATCH] Challenge #4 --- .../university/RU102J/dao/CapacityDaoRedisImpl.java | 5 ++++- .../university/RU102J/dao/CapacityDaoRedisImplTest.java | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/redislabs/university/RU102J/dao/CapacityDaoRedisImpl.java b/src/main/java/com/redislabs/university/RU102J/dao/CapacityDaoRedisImpl.java index 8e24d22..d60388c 100644 --- a/src/main/java/com/redislabs/university/RU102J/dao/CapacityDaoRedisImpl.java +++ b/src/main/java/com/redislabs/university/RU102J/dao/CapacityDaoRedisImpl.java @@ -59,7 +59,10 @@ public CapacityReport getReport(Integer limit) { @Override public Long getRank(Long siteId) { // START Challenge #4 - return -2L; + String key = RedisSchema.getCapacityRankingKey(); + try (Jedis jedis = jedisPool.getResource()) { + return jedis.zrevrank(key, siteId.toString()); + } // END Challenge #4 } } diff --git a/src/test/java/com/redislabs/university/RU102J/dao/CapacityDaoRedisImplTest.java b/src/test/java/com/redislabs/university/RU102J/dao/CapacityDaoRedisImplTest.java index 82917b6..43c0898 100644 --- a/src/test/java/com/redislabs/university/RU102J/dao/CapacityDaoRedisImplTest.java +++ b/src/test/java/com/redislabs/university/RU102J/dao/CapacityDaoRedisImplTest.java @@ -71,7 +71,6 @@ public void getReport() { } // Challenge #4 - @Ignore @Test public void getRank() { CapacityDao dao = new CapacityDaoRedisImpl(jedisPool);