]> git.donarmstrong.com Git - infobot.git/commitdiff
- fix for null factoids in factinfo.
authordms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Mon, 15 Jan 2001 13:10:52 +0000 (13:10 +0000)
committerdms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Mon, 15 Jan 2001 13:10:52 +0000 (13:10 +0000)
- added 'factstats nullfactoids'.

git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@240 c11ca15a-4712-0410-83d8-924469b57eb5

src/Modules/Factoids.pl

index 5fe634bf783fac3e91a3ac8a23382d48ac397080..2c8e9c7418aab1d762c1deefcc219bba6ccb2971 100644 (file)
@@ -33,6 +33,17 @@ sub CmdFactInfo {
        return $noreply;
     }
 
+    # fix for problem observed by asuffield.
+    # why did it happen though?
+    if (!$factinfo{'factoid_value'}) {
+       &performReply("there's no such factoid as \002$faqtoid\002; deleted because we don't have factoid_value!");
+       foreach (keys %factinfo) {
+           &DEBUG("factinfo{$_} => '$factinfo{$_}'.");
+       }
+###    &delFactoid($faqtoid);
+       return $noreply;
+    }
+
     # created:
     if ($factinfo{'created_by'}) {
 
@@ -271,6 +282,27 @@ sub CmdFactStats {
        my $prefix = "dupe factoid ";
        return &formListReply(1, $prefix, @list);
 
+    } elsif ($type =~ /^nullfactoids$/i) {
+       my $query = "SELECT factoid_key,factoid_value FROM factoids WHERE factoid_value=''";
+       my $sth = $dbh->prepare($query);
+       &ERROR("factstats(null): => '$query'.") unless $sth->execute;
+
+       my @list;
+       while (my @row = $sth->fetchrow_array) {
+           if ($row[1] ne "") {
+               &DEBUG("row[1] != NULL for $row[0].");
+               next;
+           }
+
+           &DEBUG("row[0] => '$row[0]'.");
+           push(@list, $row[0]);
+       }
+       $sth->finish;
+
+       # parse the results.
+       my $prefix = "NULL factoids (not deleted yet) ";
+       return &formListReply(1, $prefix, @list);
+
     } elsif ($type =~ /^(2|too)short$/i) {
        # Custom select statement.
        my $query = "SELECT factoid_key,factoid_value FROM factoids WHERE length(factoid_value) <= 40";