fix export_user so that it cleans out old users
authorminima <minima>
Sun, 19 Jan 2003 01:08:18 +0000 (01:08 +0000)
committerminima <minima>
Sun, 19 Jan 2003 01:08:18 +0000 (01:08 +0000)
Changes
perl/DXProt.pm
perl/DXUser.pm

diff --git a/Changes b/Changes
index cdf50df92cf1250e9683be1fcb216cd0742e91aa..f3f209d8b27381d4b5e1e259fd5fa064c966f41d 100644 (file)
--- a/Changes
+++ b/Changes
@@ -9,6 +9,8 @@ users, then you can do a set/routepc19 <node> to enable PC19 propagation. In
 the even more rare case of you wanting to prevent PC19s being routed thru 
 your node, you can use unset/routepc19. THIS IS NOT A SUBSTITUTE FOR ROUTE
 FILTERING!!!!! [translators: I have added wpc16s, wpc16u, wpc19s, wpc19u]
+2. Alter the export_user command to remove users that have no useful info
+and have not been seen for more than (default) 1 year.
 17Jan03=======================================================================
 1. Fix problem with lines being left in the main input queue for a 
 disconnected/ing node.
index 66434a0e723bf9ca89d748b79da3402cffa2a712..9a6dabf39224fd25d54b59824ddfe562f59913d7 100644 (file)
@@ -916,7 +916,8 @@ sub normal
                                                }
                                        } else {
                                                $pc19list{$call} = [] unless exists $pc19list{$call};
-                                               push @{$pc19list{$call}}, [$self->{call}, $ver, $flags];                                                
+                                               my $nl = $pc19list{$call};
+                                               push @{$pc19list{$call}}, [$self->{call}, $ver, $flags] unless grep $_->[0] eq $self->{call}, @$nl;
                                        }
                                }
 
index e5a6a3b241c37915a9e75b4073abbf28ede33631..7c9a4b369e56de0f63aabe15bf242d7e1ebe31dc 100644 (file)
@@ -25,7 +25,7 @@ $BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/  || (0,0))
 $main::build += $VERSION;
 $main::branch += $BRANCH;
 
-use vars qw(%u $dbm $filename %valid $lastoperinterval $lasttime $lru $lrusize);
+use vars qw(%u $dbm $filename %valid $lastoperinterval $lasttime $lru $lrusize $tooold);
 
 %u = ();
 $dbm = undef;
@@ -33,6 +33,7 @@ $filename = undef;
 $lastoperinterval = 60*24*60*60;
 $lasttime = 0;
 $lrusize = 2000;
+$tooold = 86400 * 365;         # this marks an old user who hasn't given enough info to be useful
 
 # hash of valid elements and a simple prompt
 %valid = (
@@ -341,6 +342,7 @@ sub export
 
        my $count = 0;
        my $err = 0;
+       my $del = 0;
        my $fh = new IO::File ">$fn" or return "cannot open $fn ($!)";
        if ($fh) {
                my $key = 0;
@@ -422,18 +424,29 @@ print "There are $count user records and $err errors\n";
                        }
                        my $ref = decode($val);
                        if ($ref) {
+                               my $t = $ref->{lastin} || 0;
+                               if ($main::systime > $t + $tooold) {
+                                       unless ($ref->{lat} && $ref->{long} || $ref->{qth} || $ref->{qra}) {
+                                               eval {$dbm->del($key)};
+                                               dbg(carp("Export Error2: $key\t$val\n$@")) if $@;
+                                               Log('DXCommand', "$ref->{call} deleted, too old");
+                                               $del++;
+                                               next;
+                                       }
+                               }
+                               # only store users that are reasonably active or have useful information
                                print $fh "$key\t" . $ref->encode . "\n";
                                ++$count;
                        } else {
-                               Log('DXCommand', "Export Error2: $key\t$val");
+                               Log('DXCommand', "Export Error3: $key\t$val");
                                eval {$dbm->del($key)};
-                               dbg(carp("Export Error2: $key\t$val\n$@")) if $@;
+                               dbg(carp("Export Error3: $key\t$val\n$@")) if $@;
                                ++$err;
                        }
                } 
         $fh->close;
     } 
-       return "$count Users $err Errors ('sh/log Export' for details)";
+       return "$count Users $del Deleted $err Errors ('sh/log Export' for details)";
 }
 
 #