From e4fe1cfa901fc5b5c1ea7004892d1715a0bae056 Mon Sep 17 00:00:00 2001 From: Benjamin Gamard Date: Tue, 21 Nov 2017 19:37:29 +0100 Subject: [PATCH] fix active user count --- .../main/java/com/sismics/docs/core/dao/jpa/UserDao.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/UserDao.java b/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/UserDao.java index c727bddb..87166a59 100644 --- a/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/UserDao.java +++ b/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/UserDao.java @@ -312,8 +312,11 @@ public class UserDao { */ public long getActiveUserCount() { EntityManager em = ThreadLocalContext.get().getEntityManager(); - Query query = em.createNativeQuery("select count(u.USE_ID_C) from T_USER u where u.USE_DELETEDATE_D is null and (u.USE_DISABLEDATE_D is null or u.USE_DISABLEDATE_D > :date)"); - query.setParameter("date", DateTime.now().minusMonths(1).toDate()); + Query query = em.createNativeQuery("select count(u.USE_ID_C) from T_USER u where u.USE_DELETEDATE_D is null and (u.USE_DISABLEDATE_D is null or u.USE_DISABLEDATE_D >= :fromDate and u.USE_DISABLEDATE_D < :toDate)"); + DateTime fromDate = DateTime.now().minusMonths(1).dayOfMonth().withMinimumValue().withTimeAtStartOfDay(); + DateTime toDate = fromDate.plusMonths(1); + query.setParameter("fromDate", fromDate.toDate()); + query.setParameter("toDate", toDate.toDate()); return ((Number) query.getSingleResult()).longValue(); } }