From 1ef05d3822686db8c8b0f495473dbc1768216b9f Mon Sep 17 00:00:00 2001 From: Nathan Cannon Date: Thu, 27 Sep 2018 16:45:26 +0100 Subject: [PATCH] Added tutor filtering? --- .../java/uk/co/neviyn/observations/dao/ObservationDao.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/backend/src/main/java/uk/co/neviyn/observations/dao/ObservationDao.java b/backend/src/main/java/uk/co/neviyn/observations/dao/ObservationDao.java index de07173..8896776 100644 --- a/backend/src/main/java/uk/co/neviyn/observations/dao/ObservationDao.java +++ b/backend/src/main/java/uk/co/neviyn/observations/dao/ObservationDao.java @@ -40,6 +40,9 @@ public class ObservationDao extends AbstractDAO { if (site != null) { predicates.add(builder.equal(root.get("site"), site)); } + if (tutor != null) { + predicates.add(builder.equal(root.join("tutors"), tutor)); + } if (startDate != null) { predicates.add(builder.greaterThanOrEqualTo(root.get("date"), startDate)); } @@ -67,7 +70,6 @@ public class ObservationDao extends AbstractDAO { * @param whom Restrict to a particular person/group who was observed. * @return Average observation scores per day. */ - // TODO: Add tutor filter public List averageStats(Site site, Tutor tutor, DateTime startDate, DateTime endDate, String whom) { CriteriaBuilder builder = currentSession().getCriteriaBuilder(); CriteriaQuery criteriaQuery = builder.createQuery(AverageStats.class); @@ -80,6 +82,9 @@ public class ObservationDao extends AbstractDAO { if (site != null) { predicates.add(builder.equal(root.get("site"), site)); } + if (tutor != null) { + predicates.add(builder.equal(root.join("tutors"), tutor)); + } if (startDate != null) { predicates.add(builder.greaterThanOrEqualTo(root.get("date"), startDate)); }