]> git.sesse.net Git - remoteglot/blobdiff - remoteglot.pl
Ignore old clock positions from the database.
[remoteglot] / remoteglot.pl
index 2b81e5c9566bd2ae7c6069e2401407ed7ef1486d..19f0446cb496128cc4fa4b04cf80f8d7ad345cdb 100755 (executable)
@@ -346,6 +346,9 @@ sub handle_position {
        # ignore it.
        if (defined($pos_calculating) && $pos->fen() eq $pos_calculating->fen()) {
                $pos_calculating->{'result'} = $pos->{'result'};
+               for my $key ('white_clock', 'black_clock', 'white_clock_target', 'black_clock_target') {
+                       $pos_calculating->{$key} //= $pos->{$key};
+               }
                return;
        }
 
@@ -564,6 +567,7 @@ sub complete_using_tbprobe {
 
                # Splice the PV from the tablebase onto what we have so far.
                for my $move (@{$pgn->moves}) {
+                       last if $move eq '#';
                        my $uci_move;
                        ($pos, $uci_move) = $pos->make_pretty_move($move);
                        push @moves, $uci_move;
@@ -1271,7 +1275,7 @@ sub find_clock_start {
        }
 
        my $id = id_for_pos($pos);
-       my $clock_info = $dbh->selectrow_hashref('SELECT * FROM clock_info WHERE id=?', undef, $id);
+       my $clock_info = $dbh->selectrow_hashref('SELECT * FROM clock_info WHERE id=? AND COALESCE(white_clock_target, black_clock_target) >= EXTRACT(EPOCH FROM (CURRENT_TIMESTAMP - INTERVAL \'1 day\'));', undef, $id);
        if (defined($clock_info)) {
                $pos->{'white_clock'} //= $clock_info->{'white_clock'};
                $pos->{'black_clock'} //= $clock_info->{'black_clock'};
@@ -1335,7 +1339,7 @@ sub schedule_tb_lookup {
        return if ($tb_lookup_running);
 
        $tb_lookup_running = 1;
-       my $url = 'http://158.250.18.203:6904/tasks/addtask?auth.login=' .
+       my $url = 'http://tb7-api.chessok.com:6904/tasks/addtask?auth.login=' .
                $remoteglotconf::tb_serial_key .
                '&auth.password=aquarium&type=0&fen=' . 
                URI::Escape::uri_escape($pos->fen());