Pivotal ID # 172918296: Views Metadata Export

Manage non existing stats in the SQL query instead of in the code
parent 5e302fca
Pipeline #79554 passed with stages
in 3 minutes and 54 seconds
package uk.ac.ebi.biostd.exporter.persistence.dao;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import lombok.AllArgsConstructor;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.stereotype.Component;
import uk.ac.ebi.biostd.exporter.persistence.Queries;
......@@ -17,15 +15,9 @@ public class StatsDao {
private final NamedParameterJdbcTemplate template;
public Integer getViews(String accNo) {
Integer views;
Map<String, String> params = ImmutableMap.of("accNo", accNo, "type", VIEW_TYPE);
try {
views = template.queryForObject(queries.getSubmissionStatsQuery(), params, Integer.class);
} catch (EmptyResultDataAccessException exception) {
views = 0;
return views;
return template.queryForObject(
ImmutableMap.of("accNo", accNo, "type", VIEW_TYPE),
......@@ -210,6 +210,6 @@
<entry key="submissionStatsQuery">
SELECT value from SubmissionStat where accNo = :accNo and type = :type
SELECT IFNULL((SELECT value from SubmissionStat where accNo = :accNo and type = :type), 0)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment