Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Govind Balaji S committed Oct 14, 2022
1 parent 0af00ef commit b0e7c82
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.redislabs.university.RU102J.api.MetricUnit;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.Pipeline;
import redis.clients.jedis.Tuple;

import java.text.DecimalFormat;
Expand All @@ -22,10 +21,10 @@
*
*/
public class MetricDaoRedisZsetImpl implements MetricDao {
static private final Integer MAX_METRIC_RETENTION_DAYS = 30;
static private final Integer MAX_DAYS_TO_RETURN = 7;
static private final Integer METRICS_PER_DAY = 60 * 24;
static private final Integer METRIC_EXPIRATION_SECONDS =
private static final Integer MAX_METRIC_RETENTION_DAYS = 30;
private static final Integer MAX_DAYS_TO_RETURN = 7;
private static final Integer METRICS_PER_DAY = 60 * 24;
private static final Integer METRIC_EXPIRATION_SECONDS =
60 * 60 * 24 * MAX_METRIC_RETENTION_DAYS + 1;
private final JedisPool jedisPool;

Expand All @@ -51,6 +50,7 @@ private void insertMetric(Jedis jedis, long siteId, double value, MetricUnit uni
// START Challenge #2
String metricKey = RedisSchema.getDayMetricKey(siteId, unit, dateTime);
Integer minuteOfDay = getMinuteOfDay(dateTime);
jedis.zadd(metricKey, minuteOfDay, value + ":" + minuteOfDay);
// END Challenge #2
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.redislabs.university.RU102J.api.MetricUnit;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;

import java.time.ZoneOffset;
Expand All @@ -20,8 +19,8 @@
public class MetricDaoRedisZsetImplTest extends JedisDaoTestBase {

private List<MeterReading> readings;
private Long siteId = 1L;
private ZonedDateTime startingDate = ZonedDateTime.now(ZoneOffset.UTC);
private final Long siteId = 1L;
private final ZonedDateTime startingDate = ZonedDateTime.now(ZoneOffset.UTC);

@After
public void flush() {
Expand All @@ -48,22 +47,19 @@ public void generateData() {
}

// Challenge #2
@Ignore
@Test
public void testSmall() {
testInsertAndRetrieve(1);
}

// Challenge #2
@Ignore
@Test
public void testOneDay() {
testInsertAndRetrieve(60 * 24);
}


// Challenge #2
@Ignore
@Test
public void testMultipleDays() {
testInsertAndRetrieve(60 * 70);
Expand Down

0 comments on commit b0e7c82

Please sign in to comment.