Skip to content
Snippets Groups Projects
Commit 7f428fa1 authored by Daniel Gerhardt's avatar Daniel Gerhardt
Browse files

Filter total answer count for questions by PI round

parent b718088f
Branches
Tags
No related merge requests found
......@@ -560,10 +560,12 @@ public class CouchDBDao implements IDatabaseDao {
}
@Override
public final int getAnswerCount(final String questionId) {
NovaView view = new NovaView("skill_question/count_answers_by_question");
view.setKey(questionId);
public final int getAnswerCount(final Question question, final int piRound) {
LOGGER.debug("coudbdao: getAnswerCount, piRound: ", piRound);
NovaView view = new NovaView("skill_question/count_total_answers_by_question_and_piround");
view.setGroup(true);
view.setStartKey(question.get_id(), String.valueOf(piRound));
view.setEndKey(question.get_id(), String.valueOf(piRound), "{}");
ViewResults results = this.getDatabase().view(view);
if (results.getResults().size() == 0) {
return 0;
......
......@@ -68,7 +68,7 @@ public interface IDatabaseDao {
List<Answer> getAnswers(String questionId, int piRound);
int getAnswerCount(String questionId);
int getAnswerCount(Question question, int piRound);
List<Answer> getFreetextAnswers(String questionId);
......
......@@ -236,11 +236,12 @@ public class QuestionService implements IQuestionService {
return getAnswers(questionId, question.getPiRound());
}
/* TODO add implementation for piRound */
@Override
@Authenticated
public int getAnswerCount(String questionId) {
return databaseDao.getAnswerCount(questionId);
Question question = getQuestion(questionId);
return databaseDao.getAnswerCount(question, question.getPiRound());
}
@Override
......
......@@ -217,7 +217,7 @@ public class StubDatabaseDao implements IDatabaseDao {
}
@Override
public int getAnswerCount(String questionId) {
public int getAnswerCount(Question question, int piRound) {
// TODO Auto-generated method stub
return 0;
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment