From a8f6f4442c54a8b5da0cb24089ea5e80fe39cef6 Mon Sep 17 00:00:00 2001
From: Daniel Gerhardt <code@dgerhardt.net>
Date: Sun, 18 Feb 2018 10:15:35 +0100
Subject: [PATCH] Fix counting of Answers for Rooms

---
 .../arsnova/persistance/couchdb/CouchDbAnswerRepository.java  | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbAnswerRepository.java b/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbAnswerRepository.java
index 90b57c9d6..a94d62168 100644
--- a/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbAnswerRepository.java
+++ b/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbAnswerRepository.java
@@ -170,7 +170,9 @@ public class CouchDbAnswerRepository extends CouchDbCrudRepository<Answer> imple
 
 	@Override
 	public int countByRoomId(final String roomId) {
-		final ViewResult result = db.queryView(createQuery("by_roomid_variant").key(roomId));
+		final ViewResult result = db.queryView(createQuery("by_roomid")
+				.key(roomId)
+				.reduce(true));
 
 		return result.isEmpty() ? 0 : result.getRows().get(0).getValueAsInt();
 	}
-- 
GitLab