From 9d5868f7b1d1f8bfc9b4d7fd680e11ab93cda9ea Mon Sep 17 00:00:00 2001
From: Daniel Gerhardt <daniel.gerhardt@mni.thm.de>
Date: Mon, 12 May 2014 21:19:01 +0200
Subject: [PATCH] Use count from UserService instead of CouchDB for active
 users

---
 .../de/thm/arsnova/services/StatisticsService.java  | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/main/java/de/thm/arsnova/services/StatisticsService.java b/src/main/java/de/thm/arsnova/services/StatisticsService.java
index 6f96824b..d94a917d 100644
--- a/src/main/java/de/thm/arsnova/services/StatisticsService.java
+++ b/src/main/java/de/thm/arsnova/services/StatisticsService.java
@@ -10,18 +10,18 @@ import de.thm.arsnova.entities.Statistics;
 @Service
 public class StatisticsService implements IStatisticsService {
 
-	private static final int DURATION_IN_MILLIS = 3 * 60 * 1000;
-
 	@Autowired
 	private IDatabaseDao databaseDao;
 
+	@Autowired
+	private IUserService userService;
+
 	@Autowired
 	private SessionRegistry sessionRegistry;
 
 	@Override
 	public final int countActiveUsers() {
-		long since = System.currentTimeMillis() - DURATION_IN_MILLIS;
-		return databaseDao.countActiveUsers(since);
+		return userService.loggedInUsers();
 	}
 
 	@Override
@@ -31,14 +31,13 @@ public class StatisticsService implements IStatisticsService {
 
 	@Override
 	public final Statistics getStatistics() {
-		long since = System.currentTimeMillis() - DURATION_IN_MILLIS;
-
 		Statistics statistics = new Statistics();
 		statistics.setOpenSessions(databaseDao.countOpenSessions());
 		statistics.setClosedSessions(databaseDao.countClosedSessions());
 		statistics.setAnswers(databaseDao.countAnswers());
 		statistics.setQuestions(databaseDao.countQuestions());
-		statistics.setActiveUsers(databaseDao.countActiveUsers(since));
+		statistics.setActiveUsers(userService.loggedInUsers());
+
 		return statistics;
 	}
 }
-- 
GitLab