# HG changeset patch # User Matti Hamalainen # Date 1401163889 -10800 # Node ID 2f0c823386b024f778be5a7432e932def15aa8d8 # Parent 48460e925a8cb08cea07163c0c2565b1e8e8e5e7 quotedb: Simplify a bit. diff -r 48460e925a8c -r 2f0c823386b0 quotedb.tcl --- 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" } }