changeset 148:2f0c823386b0

quotedb: Simplify a bit.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 27 May 2014 07:11:29 +0300
parents 48460e925a8c
children fc2654064339
files quotedb.tcl
diffstat 1 files changed, 5 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/quotedb.tcl	Sat Jun 15 01:06:10 2013 +0300
+++ b/quotedb.tcl	Tue May 27 07:11:29 2014 +0300
@@ -342,10 +342,8 @@
   }
 
   # Check if user has previously voted this item
-  set uresults 0
   set usql "SELECT id AS qid FROM ${utable}_votes WHERE user='[qdb_escape $uhand]' AND urlid=$uid"
   quotedb eval $usql {
-    incr uresults
     # Yes, update the previous vote
     set usql "UPDATE ${utable}_votes SET vote=$uvote WHERE id=$qid"
     if {[qdb_sql_exec $upublic $unick $uchan $usql]} {
@@ -357,13 +355,11 @@
     }
   }
 
-  if {$uresults == 0} {
-    # No previous votes, insert new
-    set usql "INSERT INTO ${utable}_votes (user,urlid,vote) VALUES ('[qdb_escape $uhand]',$uid,$uvote)"
-    if {[qdb_sql_exec $upublic $unick $uchan $usql]} {
-      qdb_log "$uhand voted $uvote on #$uid / $utable"
-      qdb_msg $upublic $unick $uchan "äänestit #$uid -> $uvote"
-    }
+  # No previous votes, insert new
+  set usql "INSERT INTO ${utable}_votes (user,urlid,vote) VALUES ('[qdb_escape $uhand]',$uid,$uvote)"
+  if {[qdb_sql_exec $upublic $unick $uchan $usql]} {
+    qdb_log "$uhand voted $uvote on #$uid / $utable"
+    qdb_msg $upublic $unick $uchan "äänestit #$uid -> $uvote"
   }
 }