From: Steinar H. Gunderson Date: Thu, 22 Mar 2012 00:11:58 +0000 (+0100) Subject: Output when we last synced. X-Git-Url: https://git.sesse.net/?p=wloh;a=commitdiff_plain;h=beccc37c94398d34d002a6d9a8a2dde24e8b17f6 Output when we last synced. --- diff --git a/common.pm b/common.pm new file mode 100644 index 0000000..37c59a3 --- /dev/null +++ b/common.pm @@ -0,0 +1,18 @@ +use strict; +use warnings; +use POSIX; + +package wloh_common; + +sub output_last_sync { + my $dbh = shift; + my $ref = $dbh->selectrow_hashref('SELECT EXTRACT(EPOCH FROM last_sync) AS last_sync FROM last_sync'); + if (!defined($ref)) { + print "

Databasen ble sist synkronisert (ukjent).

\n"; + } else { + my $ts = POSIX::strftime("%Y-%m-%d %H:%M %Z", localtime($ref->{'last_sync'})); + print "

Databasen ble sist synkronisert $ts.

\n"; + } +} + +1; diff --git a/sync.pl b/sync.pl index 965b6e8..178866d 100755 --- a/sync.pl +++ b/sync.pl @@ -65,5 +65,8 @@ sync_table($mdbh, $sdbh, 'Fotballspraak'); sync_table($mdbh, $sdbh, 'Fotballtoppti'); sync_table($mdbh, $sdbh, 'Fotballvariabler'); +$sdbh->do('DELETE FROM last_sync'); +$sdbh->do('INSERT INTO last_sync VALUES ( CURRENT_TIMESTAMP );'); + $mdbh->rollback(); $sdbh->commit(); diff --git a/www/index.pl b/www/index.pl index 580ad65..ec7318a 100755 --- a/www/index.pl +++ b/www/index.pl @@ -12,6 +12,7 @@ use Encode; use utf8; use locale; require '../config.pm'; +require '../common.pm'; my $cgi = CGI->new; @@ -294,6 +295,8 @@ EOF make_table($lowest_division, \%ratings, $cov); +wloh_common::output_last_sync($dbh); + print <<"EOF"; diff --git a/www/rating.pl b/www/rating.pl index 1547c42..89c75b9 100755 --- a/www/rating.pl +++ b/www/rating.pl @@ -11,6 +11,7 @@ use HTML::Entities; use utf8; use locale; require '../config.pm'; +require '../common.pm'; my $dbh = DBI->connect($config::local_connstr, $config::local_username, $config::local_password) or die "connect: " . $DBI::errstr; @@ -136,9 +137,11 @@ while (my $ref = $q->fetchrow_hashref) { printf " %s\n", $ref->{'serie_id'}, $ref->{'serie_navn'}; print " \n"; } +print " \n"; + +wloh_common::output_last_sync($dbh); print <<"EOF"; - EOF diff --git a/www/style.css b/www/style.css index 993a788..79f4d9d 100644 --- a/www/style.css +++ b/www/style.css @@ -17,3 +17,6 @@ td.num { .even { background-color: #ddd; } +.lastsync { + font-size: smaller; +}