From 207ce6c1d220682415b5ff1e8d83799932f2962f Mon Sep 17 00:00:00 2001 From: trotFunky Date: Thu, 25 Jul 2024 23:29:36 +0100 Subject: [PATCH] templates: Check vote against truth id, not number MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I made a choice to only log confirmed votes : there is no blank vote in the database. This means that when fetching a user's vote, if they have not voted for everyone there will be votes missing. As this is sent to the templating engine via a Vector, the ordering of the votes will be incorrect : all existing votes will follow each other, and there will be missing votes at the end. Update the select logic in the truth template to account for that by checking the truth_id directly, rather than via the index of the array. (O(N²)...) Remove 'has_vote' as this is not useful anymore. --- templates/index.html.tera | 9 +-------- templates/truth.html.tera | 12 +++++++----- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/templates/index.html.tera b/templates/index.html.tera index 9c8f302..f3c3c42 100644 --- a/templates/index.html.tera +++ b/templates/index.html.tera @@ -12,13 +12,6 @@ -{# Check if the user has a vote in advance, for readability #} -{% if user.logged_in == true and user.has_week_vote == true%} - {% set has_vote = true %} -{% else %} - {% set has_vote = false %} -{% endif -%} -

{{ title }}

@@ -78,7 +71,7 @@ {% if user.logged_in == true and user.is_admin == false %}