From c57888e7015d32dfb7742ca1df1d08d58220d3f2 Mon Sep 17 00:00:00 2001 From: Antonis Lempesis Date: Wed, 19 Jun 2024 11:28:26 +0300 Subject: [PATCH] initial fix --- .../statstool/repositories/StatsDBRepository.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/DBAccess/src/main/java/gr/uoa/di/madgik/statstool/repositories/StatsDBRepository.java b/DBAccess/src/main/java/gr/uoa/di/madgik/statstool/repositories/StatsDBRepository.java index 8aca813..ea93560 100644 --- a/DBAccess/src/main/java/gr/uoa/di/madgik/statstool/repositories/StatsDBRepository.java +++ b/DBAccess/src/main/java/gr/uoa/di/madgik/statstool/repositories/StatsDBRepository.java @@ -134,9 +134,9 @@ public void storeEntry(CacheEntry entry) throws Exception { } jdbcTemplate.update(query, entry.getKey(), - new ObjectMapper().writeValueAsString(entry.getResult()), - new ObjectMapper().writeValueAsString(entry.getShadowResult()), - new ObjectMapper().writeValueAsString(entry.getQuery()), + entry.getResult() == null?null:new ObjectMapper().writeValueAsString(entry.getResult()), + entry.getShadowResult() == null?null:new ObjectMapper().writeValueAsString(entry.getShadowResult()), + entry.getQuery() == null?null:new ObjectMapper().writeValueAsString(entry.getQuery()), Timestamp.from(entry.getCreated().toInstant()), Timestamp.from(entry.getUpdated().toInstant()), entry.getTotalHits(), @@ -163,7 +163,10 @@ public List getEntries() { try { QueryWithParameters query = new ObjectMapper().readValue(rs.getString("query"), QueryWithParameters.class); String key = rs.getString("key"); - Result result = new ObjectMapper().readValue(rs.getString("result"), Result.class); + Result result = null; + + if (rs.getString("result") != null) + result = new ObjectMapper().readValue(rs.getString("result"), Result.class); entry = new CacheEntry(key, query, result); @@ -203,7 +206,7 @@ public Map stats() { Map stats = new LinkedHashMap<>(); stats.put("total", jdbcTemplate.queryForObject("select count(*) from cache_entry",new Object[] {}, Integer.class)); - stats.put("with_shadow", jdbcTemplate.queryForObject("select count(*) from cache_entry where shadow is not null and shadow != ''",new Object[] {}, Integer.class)); + stats.put("with_shadow", jdbcTemplate.queryForObject("select count(*) from cache_entry where shadow is not null and shadow is not null",new Object[] {}, Integer.class)); stats.put("profiles", jdbcTemplate.query("select profile, count(key) as queries, avg(exectime) as avg_exec_time from cache_entry where key not in ('SHADOW_STATS_NUMBERS', 'STATS_NUMBERS') group by profile order by count(key) desc", (rs, rowNum) -> { Map map = new LinkedHashMap<>();