Merge pull request #1313 from jotomo/revert-behavioral-change

[Regression] Only log about records with duplicate pump id.
This commit is contained in:
Milos Kozak 2018-08-07 23:33:26 +02:00 committed by GitHub
commit 671a8030b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -381,16 +381,14 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
QueryBuilder<Treatment, Long> queryBuilder = getDao().queryBuilder();
Where where = queryBuilder.where();
where.eq("pumpId", pumpId);
PreparedQuery<Treatment> preparedQuery = queryBuilder.prepare();
List<Treatment> result = getDao().query(preparedQuery);
switch (result.size()) {
case 0:
return null;
case 1:
return result.get(0);
default:
throw new RuntimeException("Multiple records with the same pump id found: " + result.toString());
}
queryBuilder.orderBy("date", true);
List<Treatment> result = getDao().query(queryBuilder.prepare());
if (result.isEmpty())
return null;
if (result.size() > 1)
log.warn("Multiple records with the same pump id found (returning first one): " + result.toString());
return result.get(0);
} catch (SQLException e) {
throw new RuntimeException(e);
}