From: Steinar H. Gunderson Date: Mon, 23 Apr 2012 22:41:31 +0000 (+0200) Subject: Move get_max_season() into the common package. X-Git-Url: https://git.sesse.net/?p=wloh;a=commitdiff_plain;h=efea57bacf3357ae3be8c4f3053e9272e29a502b Move get_max_season() into the common package. --- diff --git a/common.pm b/common.pm index 37c59a3..7ec01a0 100644 --- a/common.pm +++ b/common.pm @@ -4,6 +4,12 @@ use POSIX; package wloh_common; +sub get_max_season { + my $dbh = shift; + my $ref = $dbh->selectrow_hashref('SELECT MAX(sesong) AS max_sesong FROM fotballserier'); + return $ref->{'max_sesong'}; +} + sub output_last_sync { my $dbh = shift; my $ref = $dbh->selectrow_hashref('SELECT EXTRACT(EPOCH FROM last_sync) AS last_sync FROM last_sync'); diff --git a/www/index.pl b/www/index.pl index fb4d8ce..109caae 100755 --- a/www/index.pl +++ b/www/index.pl @@ -39,12 +39,6 @@ sub color { return int(255.0 * ($x ** (1.80))); } -sub get_max_season { - my $dbh = shift; - my $ref = $dbh->selectrow_hashref('SELECT MAX(sesong) AS max_sesong FROM fotballserier'); - return $ref->{'max_sesong'}; -} - sub get_divisions { my ($dbh, $season) = @_; @@ -361,7 +355,7 @@ my $subdivision = $cgi->param('avdeling') // -1; my $match_player = $cgi->param('spiller'); my $match_position = $cgi->param('posisjon'); -my $season = get_max_season($dbh); +my $season = wloh_common::get_max_season($dbh); my @divisions = get_divisions($dbh, $season); $division = 1 if (!grep { $_ == $division } @divisions); my @subdivisions = get_subdivisions($dbh, $season, $division);