]> gb7djk.dxcluster.net Git - spider.git/commitdiff
WIP on spot duplicates and things
authorDirk Koopman <djk@tobit.co.uk>
Sat, 18 Jan 2025 19:00:23 +0000 (19:00 +0000)
committerDirk Koopman <djk@tobit.co.uk>
Sat, 18 Jan 2025 19:00:23 +0000 (19:00 +0000)
perl/AnnTalk.pm
perl/DXDupe.pm
perl/DXProtHandle.pm
perl/DXXml.pm
perl/Geomag.pm
perl/Spot.pm
perl/WCY.pm
perl/cluster.pl
perl/watchdbg

index defc0110aa250848e7a30e7925ee89ff8200a489..e931d5a3e08c436d690607f24a6105aa3e2c574f 100644 (file)
@@ -72,7 +72,7 @@ sub dup
        $text =~ s/[^\#a-zA-Z0-9]//g;
        $text = substr($text, 0, $duplth) if length $text > $duplth; 
        my $dupkey = "A$call|$to|\L$text";
-       return DXDupe::check($dupkey, $t);
+       return DXDupe::check_add($dupkey, $t);
 }
 
 sub listdups
index 795346db5ad89ea1d104e20a61ebffead5aee7f1..c5b4b2a0fc4df4e1e76a628c3754d0feebab7c7b 100644 (file)
@@ -15,7 +15,7 @@ use DXVars;
 
 use vars qw{$lasttime $dbm %d $default $fn};
 
-$default = 48*24*60*60;
+$default = 2*24*60*60;
 $lasttime = 0;
 localdata_mv("dupefile");
 $fn = localdata("dupefile");
@@ -36,7 +36,8 @@ sub finish
        unlink $fn;
 }
 
-sub check
+# NOTE: This checks for a duplicate and only adds a new entry if not found
+sub check_add
 {
        my $s = shift;
        return 1 if find($s);
@@ -70,17 +71,14 @@ sub del
        delete $d{$s};
 }
 
-sub process
+sub per_minute
 {
-       # once an hour
-       if ($main::systime - $lasttime >=  3600) {
-               my @del;
-               while (($k, $v) = each %d) {
-                       push @del, $k  if $main::systime >= $v;
-               }
-               del($k) for @del;
-               $lasttime = $main::systime;
+       my @del;
+       while (($k, $v) = each %d) {
+               push @del, $k  if $main::systime >= $v;
        }
+       del($k) for @del;
+       $lasttime = $main::systime;
 }
 
 sub get
@@ -99,9 +97,14 @@ sub listdups
        my $dupage = shift;
        my $regex = shift;
 
+       dbg("DXDupe::listdups let='$let' dupage='$dupage' input regex='$regex'") if isdbg('dxdupe');
+       
        $regex =~ s/[\^\$\@\%]//g;
        $regex = ".*$regex" if $regex;
        $regex = "^$let" . $regex;
+
+       dbg("DXDupe::listdups generated regex='$regex'") if isdbg('dxdupe');
+
        my @out;
        for (sort { $d{$a} <=> $d{$b} } grep { m{$regex}i } keys %d) {
                my ($dum, $key) = unpack "a1a*", $_;
index ffe91741f5091a39259d740bbe274654a9a5f8e7..868723fc4de7ee768384b27f60617d11301c10f3 100644 (file)
@@ -316,7 +316,6 @@ sub handle_11
                                return;
                        }
 
-
                        # If we have an ip address we can promote by route
                        if ($rug && $rug->ip) {
                                $pcno = 61;
@@ -347,17 +346,6 @@ sub handle_11
                }
        }
        
-       # this goes after the input filtering, but before the add
-       # so that if it is input filtered, it isn't added to the dup
-       # list. This allows it to come in from a "legitimate" source
-       #
-       ## NOTE: this is where we insert the spot into the DXDupe cache
-       #
-       if (Spot::dup(@spot[0..4,7])) {
-               dbg("PCPROT: Duplicate Spot  $self->{call}: $pc->[0] $key ignored\n") if isdbg('chanerr') || isdbg('dupespot') || isdbg('pc11');
-               return;
-       }
-
        dbg("PROCESSING $self->{call}: $pc->[0] key: $key") if isdbg('pc11');
        
        if ($pcno == 11) {
@@ -422,8 +410,26 @@ sub handle_11
                }
        }
 
+       # this goes after the input filtering, but before the actual add
+       # of the spot so that if it is input filtered, it isn't added to the dup
+       # list. This allows it to come in from a "legitimate" source
+       #
+       ## NOTE: this is where we FINALLY insert the spot into the DXDupe cache
+       ##
+       ## Jan 2025 - I have moved this here so that ONLY potential spots for
+       ##            output to users are added to the duplicate cache
+       #
+       #
+       
+       if (Spot::dup_add(0, @spot[0..4,7])) {
+               dbg("PCPROT: Duplicate Spot  $self->{call}: $pc->[0] $key ignored\n") if isdbg('chanerr') || isdbg('dupespot') || isdbg('pc11');
+               return;
+       }
+
+       #
+       # Now finally: save the spot itself and send it on its merry way to the users
+       #
        
-       # add it
        Spot::add(@spot);
 
        my $ip = '';
index f05f3d1c582d0b1fd9bb56eeb80908100c3490ee..96aedcaaf724d8ace53efee1d475af4f8f992b0e 100644 (file)
@@ -123,7 +123,7 @@ sub normal
        # now check that we have not seen this before 
        # this is based on the tuple (o (origin), t (time, normalised to time_t), id)
        $xref->{'-timet'} = $t;
-       return if DXDupe::check("xml,$o,$t,$id", $dupeage);
+       return if DXDupe::check_add("xml,$o,$t,$id", $dupeage);
                
        my $r = bless $xref, $pkg;
        $r->{'-xml'} = $line; 
index 1a56305c45a551043bac6d40953bc813d00f0e6d..523e0dc082744eaffee4048b5d664dfb86ab7430 100644 (file)
@@ -289,7 +289,7 @@ sub dup
        return 2 if $d < $main::systime - $dupage;
  
        my $dupkey = "W$d|$sfi|$k|$a|$call";
-       return DXDupe::check($dupkey, $main::systime+$dupage);
+       return DXDupe::check_add($dupkey, $main::systime+$dupage);
 }
 
 sub listdups
index 0b622a1c0b9c5fe0cfbc3d425eea7cb48b959ad9..a63bcd1097857c8726c1ffb367133198592a4b27 100644 (file)
@@ -476,10 +476,10 @@ sub formatl
        return "$s $comment$spotter";
 }
 
-# enter the spot for dup checking and return true if it is already a dup
-sub dup
+# Add the dupe if it is new. 
+sub dup_add
 {
-       my ($freq, $call, $d, $text, $by, $node, $just_find) = @_;
+       my ($just_find, $freq, $call, $d, $text, $by, $node) = @_;
 
        dbg("Spot::dup: freq=$freq call=$call d=$d text='$text' by=$by node=$node" . ($just_find ? " jf=$just_find" : "")) if isdbg('spotdup');
 
@@ -537,7 +537,7 @@ sub dup
        # new feature: don't include the origin node in Spot dupes
        # default = true
        $node = '' if $no_node_in_dupe;
-       $ldupkey = $oldstyle ? "X|$call|$by|$freq|$node|$d|$text" : "X|$call|$by|$qrg|$node|$nd|$text";
+       $ldupkey = $oldstyle ? "X$call|$by|$freq|$node|$d|$text" : "X$call|$by|$qrg|$node|$nd|$text";
        
        $t = DXDupe::find($ldupkey);
        dbg("Spot::dup ldupkey $ldupkey t '$t'" . ($t?' DUPE':' NEW')) if isdbg('spotdup');
@@ -550,7 +550,7 @@ sub dup
        $otext = substr($otext, 0, $duplth) if length $otext > $duplth; 
        $otext =~ s/\s+$//;
        if (length $otext && $otext ne $text) {
-               $ldupkey = $oldstyle ? "X|$call|$by|$freq|$otext" : "X|$call|$by|$qrg|$otext";
+               $ldupkey = $oldstyle ? "X$call|$by|$freq|$otext" : "X$call|$by|$qrg|$otext";
                $t = DXDupe::find($ldupkey);
                dbg("Spot::dup (OTEXT) ldupkey $ldupkey t '$t'" . ($t?' DUPE':' NEW')) if isdbg('spotdup');
                if (isdbg('spottext')) {
@@ -566,7 +566,7 @@ sub dup
 
 sub dup_find
 {
-       return dup(@_, 1);
+       return dup_add(1, @_);
 }
 
 sub listdups
index ef536ddb2fa8681c986766f67537f84d1cc7fefb..1d46a8e2682b65b200c44d71fa97ebf8381a0613 100644 (file)
@@ -263,7 +263,7 @@ sub dup
        return 2 if $d < $main::systime - $dupage;
  
        my $dupkey = "C$d";
-       return DXDupe::check($dupkey, $main::systime+$dupage);
+       return DXDupe::check_add($dupkey, $main::systime+$dupage);
 }
 
 sub listdups
index f7c85a6f9a18ad2bb4fe12672eb5cdba06c4002d..a4c831aa1293bdf7f6cce6c361e40cb8239d8feb 100755 (executable)
@@ -871,7 +871,6 @@ sub per_sec
        DXMsg::process();
        DXDb::process();
        DXUser::process();
-       DXDupe::process();
        IsoTime::update($systime);
        DXConnect::process();
        DXUser::process();
@@ -891,6 +890,7 @@ sub per_10_sec
 sub per_minute
 {
        RBN::per_minute();
+       DXDupe::per_minute();
 }
 
 sub per_10_minute
index 2b1986a738bd4e4236b582ac4d1957ce6d2f4696..5fa7ebb2d7b6f9cb494d9f45f08f5d39f1de830c 100755 (executable)
@@ -54,6 +54,7 @@ while (@ARGV) {
 # seek to end of file
 $fh->seek(0, 2);
 for (;;) {
+       $fh->seek(0, 1);
        my $line = $fh->getline;
        if ($line) {
                if (@patt) {