From ca155f88382459eb7f151b5bea51231263eb5b7e Mon Sep 17 00:00:00 2001 From: Aaron Detre Date: Mon, 21 Apr 2025 11:48:06 -0700 Subject: [PATCH] Compare student login times to the start of the day rather than the current time --- .../attendance/impl/HibernateStudentAttendanceDao.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/org/wise/portal/dao/attendance/impl/HibernateStudentAttendanceDao.java b/src/main/java/org/wise/portal/dao/attendance/impl/HibernateStudentAttendanceDao.java index b88eef9118..a048afce6d 100644 --- a/src/main/java/org/wise/portal/dao/attendance/impl/HibernateStudentAttendanceDao.java +++ b/src/main/java/org/wise/portal/dao/attendance/impl/HibernateStudentAttendanceDao.java @@ -76,6 +76,10 @@ public List getStudentAttendanceByRunIdAndPeriod( List predicates = new ArrayList<>(); Calendar c = Calendar.getInstance(); c.add(Calendar.DAY_OF_YEAR, -lookBackNumDays); + this.roundDownCalendar(c, Calendar.HOUR_OF_DAY); + this.roundDownCalendar(c, Calendar.MINUTE); + this.roundDownCalendar(c, Calendar.SECOND); + this.roundDownCalendar(c, Calendar.MILLISECOND); Date compareDate = c.getTime(); predicates.add( cb.greaterThanOrEqualTo(studentAttendanceRoot.get("loginTimestamp"), compareDate)); @@ -86,6 +90,10 @@ public List getStudentAttendanceByRunIdAndPeriod( return (List) (Object) query.getResultList(); } + private void roundDownCalendar(Calendar c, int timeUnit) { + c.add(timeUnit, -c.get(timeUnit)); + } + @Override protected Class getDataObjectClass() { return null;