]> git.sesse.net Git - ccbs/blobdiff - parse/parse-ddreurope-tournament.pl
Update the parser scripts to handle tournament rankings, and fix a typo in the SQL...
[ccbs] / parse / parse-ddreurope-tournament.pl
index 5773f13648428f863d5d2e7953573683cc873a78..b0da713c3ad7523610a6395807122a396867d928 100644 (file)
@@ -140,6 +140,32 @@ while (<>) {
                print "  round=$round;\n";
        }
 
+       # First place
+       if (/A \s* well-earned \s* victory \s* for .*? class="link"> (.*?) <\/a> (?: , \s* who \s* got \s* (\d+) \s* point )?/x) {
+               my $nick = $1;
+               my $points = $2;
+
+               # Whoa :-)
+               $points = 'NULL' unless defined($points);
+
+               print "INSERT INTO tournamentrankings (tournament, ranking, player, points) VALUES (\n";
+               print "   (SELECT tournament FROM tournaments WHERE tournamentname='$name'),\n";
+               print "   1, '$nick', $points);\n";
+       }
+
+       # All other places
+       while (s/(\d+) (?: st | nd | rd | th ) \s* place: .*? class="link"> (.*?) <\/a> \s* (?: got \s* (\d+) \s* point )?//x) {
+               my $ranking = $1;       
+               my $nick = $2;
+               my $points = $3;
+
+               # Whoa :-)
+               $points = 'NULL' unless defined($points);
+
+               print "INSERT INTO tournamentrankings (tournament, ranking, player, points) VALUES (\n";
+               print "   (SELECT tournament FROM tournaments WHERE tournamentname='$name'),\n";
+               print "   $ranking, '$nick', $points);\n";
+       }       
 }
 
 printf "commit;\n";