From 28c2a1a792fd9912b5cf758ee872d9b5e42ae2d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20A=2E=20I=2E=20L=C3=B3pez?= <17472377+J-A-I-L@users.noreply.github.com> Date: Wed, 6 Jul 2022 18:18:45 +0200 Subject: [PATCH] Challenge #4 Implement `getRAnk()` in `CapacityDaoRedisImplTest.java`. --- .../university/RU102J/dao/CapacityDaoRedisImpl.java | 7 ++++++- .../university/RU102J/dao/CapacityDaoRedisImplTest.java | 1 - 2 files changed, 6 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..2c9d884 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,12 @@ 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()) { + final Long rank = jedis.zrevrank(key, siteId.toString()); + return rank; + } // 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);