6 use POSIX qw
/strftime/;
8 $SIG{__WARN__
} = sub { cluck
$_[0] };
10 my $ctx = ASR
::Ladder
->new;
12 $ctx->header('Monthly reset');
14 if ($ctx->param('pwd') ne $ctx->{adminpw
}) {
15 print $ctx->p('Invalid password.');
20 =can trigger infinite
loop :/
21 if ((system('mysqldump -u asr -p'.$ctx->{password
}.' asr >/tmp/ASR-`date +%F`.dump') >> 8) != 0) {
22 print $ctx->p("Error: Database backup failed: $?, $!");
28 ($ctx->db_do('START TRANSACTION') and
29 $ctx->db_do('CREATE TEMPORARY TABLE inactive (id INT)') and
30 $ctx->db_do('INSERT INTO inactive SELECT id FROM raw_ladder ' .
31 'WHERE last_game IS NULL OR last_game < ' .
32 'DATE("'.$ctx->param('cutoffdate').'")') and
33 $ctx->db_do('DELETE FROM player WHERE id IN (SELECT id FROM inactive)') and
34 $ctx->db_do('DROP TABLE inactive') and
35 $ctx->db_do('COMMIT')) or
36 print $ctx->p('Removing inactive players failed.');
38 $ctx->db_do('UPDATE player SET score = 100 WHERE score < 100') or
39 print $ctx->p('Flooring score to 100 failed.');
40 $ctx->db_do('UPDATE player SET score = 200 WHERE score > 200') or
41 print $ctx->p('Ceiling score to 200 failed.');
42 $ctx->db_do('UPDATE player SET score = 100 + (score - 100) / 2 WHERE score > 100') or
43 print $ctx->p('Halving score failed.');