From 1adc49b8f71e09c5f925891ccc29fdcbd48b2229 Mon Sep 17 00:00:00 2001 From: timriker 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/blootbot@735 c11ca15a-4712-0410-83d8-924469b57eb5 --- src/Factoids/Question.pl | 18 +++++------------- src/IRC/IrcHooks.pl | 19 ++++--------------- src/Misc.pl | 23 +++++++---------------- src/Process.pl | 11 ++++++----- 4 files changed, 22 insertions(+), 49 deletions(-) diff --git a/src/Factoids/Question.pl b/src/Factoids/Question.pl index 74a2416..7d6f27c 100644 --- a/src/Factoids/Question.pl +++ b/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/src/IRC/IrcHooks.pl b/src/IRC/IrcHooks.pl index b63c405..e8c4efa 100644 --- a/src/IRC/IrcHooks.pl +++ b/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/src/Misc.pl b/src/Misc.pl index 04ace3f..1965db2 100644 --- a/src/Misc.pl +++ b/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/src/Process.pl b/src/Process.pl index 22ab7a8..3563866 100644 --- a/src/Process.pl +++ b/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.2