]> git.donarmstrong.com Git - infobot.git/blobdiff - src/Modules/Factoids.pl
fix count(*)
[infobot.git] / src / Modules / Factoids.pl
index 729ec8e77a7969e2b54a16995a9e2fe411615ebb..1265ab5580c11b399193cb6b9694468146edc7c8 100644 (file)
@@ -64,8 +64,8 @@ sub CmdFactInfo {
        push(@array,$string);
     }
 
-    # modified:
-    if (0 && $factinfo{'modified_by'}) {
+    # modified: (TimRiker asks "why do you keep turning this off?)
+    if ($factinfo{'modified_by'}) {
        $string = "last modified";
 
        my $time = $factinfo{'modified_time'};
@@ -136,14 +136,14 @@ sub CmdFactStats {
     my ($type) = @_;
 
     if ($type =~ /^author$/i) {
-       my @array = &sqlSelectColArray("factoids",
+       my %hash = &sqlSelectColHash("factoids",
                "factoid_key,created_by", { },
                "created_by IS NOT NULL"
        );
        my %author;
 
-       foreach (@array) {
-           my $thisnuh = $hash{$_};
+       foreach my $factoid (keys %hash) {
+           my $thisnuh = $hash{$factoid};
 
            $thisnuh =~ /^(\S+)!\S+@\S+$/;
            $author{lc $1}++;
@@ -180,7 +180,7 @@ sub CmdFactStats {
        my @list;
 
        my $delta_time  = &timedelta($start_time);
-        &status(sprintf("factstats(vandalismbroken): %.02f sec to retreive all factoids.", $delta_time)) if ($delta_time > 0);
+        &status(sprintf("factstats(vandalism): %.02f sec to retreive all factoids.", $delta_time)) if ($delta_time > 0);
        $start_time     = &timeget();
 
        # parse the factoids.
@@ -537,6 +537,7 @@ sub CmdFactStats {
                        "factoid_value", "^<REPLY> see ");
        my %redir;
        my $f;
+       my $dangling = 0;
 
        for (@list) {
            my $factoid = $_;
@@ -547,7 +548,8 @@ sub CmdFactStats {
                if (defined $redirval) {
                    $redir{$redir}{$factoid} = 1;
                } else {
-                   &WARN("factstats(redir): '$factoid' has loose link => '$redir'.");
+                   &DEBUG("factstats(redir): '$factoid' has loose link => '$redir'.");
+                   $dangling++;
                }
            }
        }
@@ -563,7 +565,7 @@ sub CmdFactStats {
        }
 
        # parse the results.
-       my $prefix = "Redirections in factoids ";
+       my $prefix = "Redirections in factoids, $dangling dangling ";
        return &formListReply(1, $prefix, @newlist);
 
     } elsif ($type =~ /^request(ed)?$/i) {
@@ -667,7 +669,7 @@ sub CmdFactStats {
        for (@list) {
            my $factoid = $_;
            my $val = &getFactInfo($factoid, "factoid_value");
-       
+
            next unless ($val =~ /^see( also)? (.*?)\.?$/i);
 
            my $redirf  = lc $2;
@@ -726,14 +728,9 @@ sub CmdFactStats {
 
     } elsif ($type =~ /^unrequest(ed)?$/i) {
        # todo: use sqlSelect()
-       my @list = &sqlRawReturn("SELECT factoid_key FROM factoids WHERE requested_count IS NULL");
-
-       for (@list) {
-           s/([\,\;]+)/\037$1\037/g;
-       }
+       my ($count) = &sqlRawReturn("SELECT COUNT(*) FROM factoids WHERE requested_count = '0'");
 
-       my $prefix = "Unrequested factoids ";
-       return &formListReply(0, $prefix, @list);
+       return "Unrequested factoids: $count";
     }
 
     return "error: invalid type => '$type'.";