From e32be7e80426772f8db69c2c2d64ce85f96f7cfe Mon Sep 17 00:00:00 2001
From: timriker <timriker@c11ca15a-4712-0410-83d8-924469b57eb5>
Date: Sat, 7 Dec 2002 00:23:13 +0000
Subject: [PATCH] foo+1 does not work on sqlReplace for sqlite. odd thing is
 that is does work on sqlUpdate. avoid it when it's easy.

git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk@735 c11ca15a-4712-0410-83d8-924469b57eb5
---
 blootbot/src/Factoids/Question.pl | 18 +++++-------------
 blootbot/src/IRC/IrcHooks.pl      | 19 ++++---------------
 blootbot/src/Misc.pl              | 23 +++++++----------------
 blootbot/src/Process.pl           | 11 ++++++-----
 4 files changed, 22 insertions(+), 49 deletions(-)

diff --git a/blootbot/src/Factoids/Question.pl b/blootbot/src/Factoids/Question.pl
index 74a2416..7d6f27c 100644
--- a/blootbot/src/Factoids/Question.pl
+++ b/blootbot/src/Factoids/Question.pl
@@ -246,19 +246,11 @@ sub factoidArgs {
 	}
 
 	# update stats.
-	if (0) {	# old.
-	    my $count = &getFactInfo($q, "requested_count") || 0;
-	    $count++;
-	    &setFactInfo($q, "requested_by", $nuh);
-	    &setFactInfo($q, "requested_time", time());
-	    &setFactInfo($q, "requested_count", $count);
-	} else {
-	    &sqlUpdate("factoids", { factoid_key => $q }, {
-		requested_by		=> $nuh,
-		requested_time		=> time(),
-		-requested_count	=> "requested_count+1",
-	    } );
-	}
+	&sqlUpdate("factoids", { factoid_key => $q }, {
+	    requested_by	=> $nuh,
+	    requested_time	=> time(),
+	    -requested_count	=> "requested_count+1",
+	} );
 
 	# end of update stats.
 
diff --git a/blootbot/src/IRC/IrcHooks.pl b/blootbot/src/IRC/IrcHooks.pl
index b63c405..e8c4efa 100644
--- a/blootbot/src/IRC/IrcHooks.pl
+++ b/blootbot/src/IRC/IrcHooks.pl
@@ -893,24 +893,13 @@ sub on_public {
 	    next unless (defined $t);
 	    next unless ($time - $t > 10);
 
-	    my %hash = (
-		nick	=> $who,
-		type	=> $x,
+	    &sqlReplace("stats", {
+		nick => $who,
+		type => $x,
 		channel => $c,
-
 		time	=> $time,
 		counter => $v,
-	    );
-		
-	    if (0) {
-		&sqlReplace("stats", \%hash);
-	    } else {
-		&sqlReplace("stats", {
-			nick => $who,
-			type => $x,
-			-counter => "counter+1",
-		} );
-	    }
+	    } );
 	}
     }
 
diff --git a/blootbot/src/Misc.pl b/blootbot/src/Misc.pl
index 04ace3f..1965db2 100644
--- a/blootbot/src/Misc.pl
+++ b/blootbot/src/Misc.pl
@@ -644,22 +644,13 @@ sub closeStats {
 
 	$i	+= $cmdstats{$type};
 
-	my %hash = (
-		nick => $type,
-		type => "cmdstats",
-		counter => $i
-	);		
-	$hash{time} = time() if ($z);
-
-	if (0) {
-	    &sqlReplace("stats", %hash);
-	} else {
-	    &sqlReplace("stats", {
-		nick		=> $type,
-		type		=> "cmdstats",
-		-counter	=> "counter+1",
-	    } );
-	}
+
+	&sqlReplace("stats", {
+	    nick	=> $type,
+	    type	=> "cmdstats",
+	    'time'	=> time(),
+	    counter	=> $i,
+	} );
     }
 }
 
diff --git a/blootbot/src/Process.pl b/blootbot/src/Process.pl
index 22ab7a8..3563866 100644
--- a/blootbot/src/Process.pl
+++ b/blootbot/src/Process.pl
@@ -322,11 +322,12 @@ sub process {
 	    $karma--;
 	}
 
-	&sqlSet("stats", 
-		{ nick => $term, type => "karma" },	# WHERE
-#		{ counter => $karma }			# WHAT
-		{ -counter => "counter+1" }
-	);
+	&sqlReplace("stats", {
+	    nick	=> $term,
+	    type	=> "karma",
+	    'time'	=> time(),
+	    counter	=> $karma,
+	} );
 
 	return;
     }
-- 
2.39.5