Bugfix: adding zero counts that were skipped

This commit is contained in:
Vivek Santayana 2022-09-01 11:56:15 +01:00
parent b2df303632
commit 0c49d22865

View File

@ -38,15 +38,14 @@ def _playbooks():
@views.route('/answers/') @views.route('/answers/')
def _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 entry in Entry.query.all():
for index, answer in enumerate(entry.answers): for index, answer in enumerate(entry.answers):
if index not in answers: answers[index] = { }
if type(answer) is list: if type(answer) is list:
for option in answer: for option in answer: answers[index][option] += 1
if option not in answers[index]: answers[index][option] = 0
answers[index][option] += 1
else: else:
if answer not in answers[index]: answers[index][answer] = 0
answers[index][answer] += 1 answers[index][answer] += 1
return list(answers.values()) return list(answers.values())