Caretaker.pl

From Organic Design wiki
Revision as of 01:33, 24 October 2006 by Nad (talk | contribs) (empty article loop ready for tasks)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

use DBI; my $dbh = DBI->connect('DBI:mysql:wiki',$::peer,$::pwd1) or die DBI->errstr; @ns = (,'Talk:','User:','User talk:','Project:','Project talk:', 'Image:','Image talk:','Mediawiki:','Mediawiki talk:','Template:', 'Template talk:','Help:','Help talk:','Category:','Category talk:');

  1. Get last article id

my $sth = $dbh->prepare('SELECT cur_id FROM cur ORDER BY cur_id DESC'); $sth->execute(); my @row = $sth->fetchrow_array; $sth->finish; my $last = $row[0];

  1. Loop through all articles one per second

my $sth = $dbh->prepare('SELECT cur_namespace,cur_title FROM cur WHERE cur_id=?$ my $done = 0; for (0..$last) { $sth->execute($_); @row = $sth->fetchrow_array; if (my $title = $ns[$row[0]].$row[1]) { } sleep(1); }

my $comment = "Caretaking tasks completed: $last articles examined, $done adjusted."; logAdd $comment; wikiLogin($::wiki, $::peer, $::pwd1); wikiPageAppend($::wiki, $::wikilog, "\n*".localtime()." : $comment", $comment); $sth->finish; $dbh->disconnect;