This is an automated email from the ASF dual-hosted git repository.

humbedooh pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/steve.git


The following commit(s) were added to refs/heads/trunk by this push:
     new cdfbbb5  Fix has_voted call
cdfbbb5 is described below

commit cdfbbb5ac13f12c44d7be45f5b436b4abc23bbe0
Author: Daniel Gruno <[email protected]>
AuthorDate: Fri Feb 21 10:08:14 2025 +0100

    Fix has_voted call
    
    - doc_type is clearly a copypasto from ES, so nix that
    - both eid and the more cryptic vhash may be used for document ID, so look 
for both.
---
 pysteve/lib/backends/sqlite.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/pysteve/lib/backends/sqlite.py b/pysteve/lib/backends/sqlite.py
index cbc8fa9..a9e0e36 100644
--- a/pysteve/lib/backends/sqlite.py
+++ b/pysteve/lib/backends/sqlite.py
@@ -266,9 +266,11 @@ class SQLiteBackend:
 
     def voter_has_voted(self, election, issue, uid):
         "Return true if the voter has voted on this issue, otherwise false"
+        # a vote trail can be either the old eid or the vhash.
         eid = constants.hexdigest(election + ":" + issue + ":" + uid)
+        vhash = constants.hexdigest(constants.hexdigest(election + ":" + uid) 
+ issue)
         try:
-            return self.DB.db.fetchone(doc_type="votes", id=eid)
+            return self.DB.db.fetchone("votes", id=eid) or 
self.DB.db.fetchone("votes", id=vhash)
         except:
             return False
 

Reply via email to