You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@steve.apache.org by gs...@apache.org on 2026/02/22 02:59:51 UTC
(steve) 02/04: refactor: shuffle candidates in vote_on_page to prevent bias
This is an automated email from the ASF dual-hosted git repository.
gstein pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/steve.git
commit 65d13fa86b456525360693dcf60afdfd2ee037e9
Author: Greg Stein <gs...@gmail.com>
AuthorDate: Sat Feb 21 20:43:33 2026 -0600
refactor: shuffle candidates in vote_on_page to prevent bias
Co-authored-by: aider (openrouter/x-ai/grok-code-fast-1) <ai...@aider.chat>
---
v3/server/pages.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/v3/server/pages.py b/v3/server/pages.py
index a86338e..305dd51 100644
--- a/v3/server/pages.py
+++ b/v3/server/pages.py
@@ -24,6 +24,7 @@ import pathlib
import datetime
import functools
import logging
+import random
from easydict import EasyDict as edict
import asfpy.stopwatch
@@ -280,7 +281,8 @@ async def vote_on_page(election):
issue.seats = issue.kv.get('seats', 0)
issue.labelmap = edict(issue.kv.get('labelmap', {}))
issue.candidates = [{'label': k, 'name': v} for k, v in issue.labelmap.items()]
- issue.candidates.sort(key=lambda c: c['name']) # Sort candidates by name for consistency
+ # Shuffle candidates to prevent bias towards the first listed candidate
+ random.shuffle(issue.candidates)
# Compute counts and plurals
yna_count = len(issues_yna)