From 0c49d22865de37824d87f6c20bbff2dd7cbd2522 Mon Sep 17 00:00:00 2001 From: viveksantayana Date: Thu, 1 Sep 2022 11:56:15 +0100 Subject: [PATCH] Bugfix: adding zero counts that were skipped --- server/app/views.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/server/app/views.py b/server/app/views.py index d7f6e87..33be51b 100644 --- a/server/app/views.py +++ b/server/app/views.py @@ -37,16 +37,15 @@ def _playbooks(): @views.route('/answers/') def _answers(): - answers = {} + answers = { } + for index, question in enumerate(render_questions()): + answers[index] = { } + for _index, answer in enumerate(question['answers']): answers[index][_index] = 0 for entry in Entry.query.all(): for index, answer in enumerate(entry.answers): - if index not in answers: answers[index] = { } if type(answer) is list: - for option in answer: - if option not in answers[index]: answers[index][option] = 0 - answers[index][option] += 1 + for option in answer: answers[index][option] += 1 else: - if answer not in answers[index]: answers[index][answer] = 0 answers[index][answer] += 1 return list(answers.values())