]> git.sesse.net Git - ccbs/blob - html/do-update-shorttitles.pl
Replace the web frontend's rank calculations with the stored procedures.
[ccbs] / html / do-update-shorttitles.pl
1 #! /usr/bin/perl
2
3 use ccbs;
4 use strict;
5 use warnings;
6
7 ccbs::admin_only();
8
9 my $dbh = ccbs::db_connect();
10 my $cgi = new CGI;
11
12 # This is ugly, but we don't need more than one people updating this at a
13 # time anyhow (we hope).
14 $dbh->{AutoCommit} = 0;
15 $dbh->{RaiseError} = 1;
16 $dbh->do('DELETE FROM songshorttitles');
17
18 for my $p ($cgi->param()) {
19         $p =~ /^st(\d+)$/ or next;
20         my $num = $1;
21         my $st = $cgi->param($p);
22
23         my $q = $dbh->prepare('INSERT INTO songshorttitles (song, shorttitle) VALUES (?, ?)');
24         if ($st !~ /^\s*$/) {
25                 $q->execute($num, $st);
26         }
27 }
28
29 # This will make the big screen use the new short titles, if it needs them
30 $dbh->do('NOTIFY scores');
31
32 $dbh->commit;
33
34 $dbh->disconnect;
35
36 ccbs::print_see_other('shorttitles.pl');
37