my $ref = $dbh->selectrow_hashref('SELECT sesong FROM fotballserier GROUP BY sesong HAVING COUNT(*)=COUNT(avgjort=1 OR NULL) ORDER BY sesong DESC LIMIT 1');
my $last_season = $ref->{'sesong'};
my $ref = $dbh->selectrow_hashref('SELECT sesong FROM fotballserier GROUP BY sesong HAVING COUNT(*)=COUNT(avgjort=1 OR NULL) ORDER BY sesong DESC LIMIT 1');
my $last_season = $ref->{'sesong'};
-my $tmpnam = POSIX::tmpnam();
-open DATA, ">", $tmpnam
- or die "$tmpnam: $!";
-
-# Fetch name (ID) list
-my $q = $dbh->prepare('SELECT DISTINCT id FROM fotballdeltagere');
-$q->execute();
-my @ids = ();
-while (my $ref = $q->fetchrow_hashref) {
- my $id = $ref->{'id'};
- push @ids, $id;
-}
-
-print DATA scalar @ids, "\n";
-for my $id (@ids) {
- print DATA $id, "\n";
-}
-
# Fetch games
# Fetch games
-$q = $dbh->prepare('
+my $q = $dbh->prepare('
SELECT
deltager1.id as p1, deltager2.id as p2, maalfor, maalmot, least(pow(2.0, (sesong - ? + 3) / 3.0), 1.0) AS vekt
FROM
SELECT
deltager1.id as p1, deltager2.id as p2, maalfor, maalmot, least(pow(2.0, (sesong - ? + 3) / 3.0), 1.0) AS vekt
FROM
@@ -46,13+28,30 @@ WHERE deltager1.Nr > deltager2.nr
');
$q->execute($last_season);
');
$q->execute($last_season);
+my @games = ();
+my %ids = ();
+
while (my $ref = $q->fetchrow_hashref) {
next if ($ref->{'maalfor'} == 150 && $ref->{'maalmot'} == 0);
next if ($ref->{'maalfor'} == 0 && $ref->{'maalmot'} == 150);
next if ($ref->{'maalfor'} == 150 && $ref->{'maalmot'} == 150);
while (my $ref = $q->fetchrow_hashref) {
next if ($ref->{'maalfor'} == 150 && $ref->{'maalmot'} == 0);
next if ($ref->{'maalfor'} == 0 && $ref->{'maalmot'} == 150);
next if ($ref->{'maalfor'} == 150 && $ref->{'maalmot'} == 150);