From 0430b6c050ca44e8a3dbf01befc1656c5b5288c6 Mon Sep 17 00:00:00 2001 From: matejkec Date: Thu, 4 May 2023 20:28:58 +0200 Subject: [PATCH] Implement Challenge #2 --- .../university/RU102J/dao/MetricDaoRedisZsetImpl.java | 3 +-- .../university/RU102J/dao/MetricDaoRedisZsetImplTest.java | 3 --- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/com/redislabs/university/RU102J/dao/MetricDaoRedisZsetImpl.java b/src/main/java/com/redislabs/university/RU102J/dao/MetricDaoRedisZsetImpl.java index 49da2ec..01bc8e9 100644 --- a/src/main/java/com/redislabs/university/RU102J/dao/MetricDaoRedisZsetImpl.java +++ b/src/main/java/com/redislabs/university/RU102J/dao/MetricDaoRedisZsetImpl.java @@ -48,10 +48,9 @@ public void insert(MeterReading reading) { // Challenge #2 private void insertMetric(Jedis jedis, long siteId, double value, MetricUnit unit, ZonedDateTime dateTime) { - // START Challenge #2 String metricKey = RedisSchema.getDayMetricKey(siteId, unit, dateTime); Integer minuteOfDay = getMinuteOfDay(dateTime); - // END Challenge #2 + jedis.zadd(metricKey, minuteOfDay, new MeasurementMinute(value, minuteOfDay).toString()); } /** diff --git a/src/test/java/com/redislabs/university/RU102J/dao/MetricDaoRedisZsetImplTest.java b/src/test/java/com/redislabs/university/RU102J/dao/MetricDaoRedisZsetImplTest.java index 30e1072..ef26aab 100644 --- a/src/test/java/com/redislabs/university/RU102J/dao/MetricDaoRedisZsetImplTest.java +++ b/src/test/java/com/redislabs/university/RU102J/dao/MetricDaoRedisZsetImplTest.java @@ -48,14 +48,12 @@ public void generateData() { } // Challenge #2 - @Ignore @Test public void testSmall() { testInsertAndRetrieve(1); } // Challenge #2 - @Ignore @Test public void testOneDay() { testInsertAndRetrieve(60 * 24); @@ -63,7 +61,6 @@ public void testOneDay() { // Challenge #2 - @Ignore @Test public void testMultipleDays() { testInsertAndRetrieve(60 * 70);