Sat, 17 Feb 2024 15:36:09 +0100
demon.php: ease some db pressure by not querying old entries (7 days).
- replaced some rejects workaround by exclusions
- some moar debug msgs
delinquent_files/demon.php | file | annotate | diff | comparison | revisions |
--- a/delinquent_files/demon.php Sat Feb 17 15:34:18 2024 +0100 +++ b/delinquent_files/demon.php Sat Feb 17 15:36:09 2024 +0100 @@ -1,6 +1,10 @@ #!/usr/bin/php +#$Id$ +# + <?PHP + chdir ( '/data/project/commons-delinquent' ) ; error_reporting(E_ERROR|E_CORE_ERROR|E_COMPILE_ERROR); # E_ALL| @@ -10,6 +14,8 @@ require_once( './matcher.inc' ); require_once( './debug.inc' ); +print "Bot startup in progress...\n"; + class CommonsDelinquentDemon extends CommonsDelinquent { var $avoidNamespaceOnWiki = [ @@ -155,12 +161,16 @@ function getTextFromWiki ( $wiki , $pagename ) { $ret = false ; $this->d->debug( "Getting api of " . $wiki) ; + // temp workaround 3/22/2023 + //if ($wiki === 'bclwiktionary' || $wiki === 'bjnwiktionary' || $wiki === 'gorwiktionary') { + // return false; + //} $api = $this->getAPI ( $wiki ) ; if ( $api ) { $services = new \Mediawiki\Api\MediawikiFactory( $api ); $page = $services->newPageGetter()->getFromTitle( $pagename ); $revision = $page->getRevisions()->getLatest(); - + if ( $revision ) { $ret = $revision->getContent()->getData() ; } @@ -475,14 +485,17 @@ } function clearBogusIssues ( $db ) { + + $ts = date ( 'YmdHis' , time() - 60*60*24*7 ); # look back 7 days only + # Clear some previous issues // 0=pending // 1=done // 2=skipped - $sql = "update `event` set done=0,note='' where note like '%rate limit%' and done=2" ; + $sql = "update `event` set done=0,note='' where note like '%rate limit%' and done=2 and timestamp>'$ts'" ; $this->d->debug("Set done=0 (pending) on 'rate limit' events where done=2(skipped)"); $this->runQuery ( $db , $sql ) ; - $sql = "update `event` set done=0,note='' where note like '%edit conflict%' and done=2" ; + $sql = "update `event` set done=0,note='' where note like '%edit conflict%' and done=2 and timestamp>'$ts'" ; $this->d->debug("Set done=0 (pending) on 'edit conflict' events where done=2(skipped)"); $this->runQuery ( $db , $sql ) ; } @@ -509,7 +522,7 @@ try { $this->performEdit ( $o ) ; } catch (Exception $e) { - echo 'Caught exception: ', $e->getMessage(), "\n"; + echo 'Caught exception: ', $e->getMessage(), "\n"; } $last_wiki = $o->wiki ; }