]> git.sesse.net Git - wloh/commitdiff
Output when we last synced.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 22 Mar 2012 00:11:58 +0000 (01:11 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 22 Mar 2012 00:11:58 +0000 (01:11 +0100)
common.pm [new file with mode: 0644]
sync.pl
www/index.pl
www/rating.pl
www/style.css

diff --git a/common.pm b/common.pm
new file mode 100644 (file)
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 "    <p class=\"lastsync\">Databasen ble sist synkronisert (ukjent).</p>\n";
+       } else {
+               my $ts = POSIX::strftime("%Y-%m-%d %H:%M %Z", localtime($ref->{'last_sync'}));
+               print "    <p class=\"lastsync\">Databasen ble sist synkronisert $ts.</p>\n";
+       }
+}
+
+1;
diff --git a/sync.pl b/sync.pl
index 965b6e83a606cf8d3daeeca54de7ed9816aeb7d5..178866de7d438812b473d25c59ba5773c574b54a 100755 (executable)
--- 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();
index 580ad658d040da70b5da15c635fb93da7a8baf79..ec7318a4079685aca9f500b41123ab4df27f24b8 100755 (executable)
@@ -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";
   </body>
 </html>
index 1547c42d2f0a794eea49b9aee7a5b8afcf26542d..89c75b96e2ee89a6e64f862fd61bc8757ce5c096 100755 (executable)
@@ -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 "      <td><a href=\"http://wordfeud.aasmul.net/serie-%d\">%s</a></td>\n", $ref->{'serie_id'}, $ref->{'serie_navn'};
        print "    </tr>\n";
 }
+print "    </table>\n";
+
+wloh_common::output_last_sync($dbh);
 
 print <<"EOF";
-    </table>
   </body>
 </html>
 EOF
index 993a788eee027800e795662a5a46dfb8ebd9e0b9..79f4d9d5d9ebce070fd6e452d36e92e4439197c8 100644 (file)
@@ -17,3 +17,6 @@ td.num {
 .even {
        background-color: #ddd;
 }
+.lastsync {
+       font-size: smaller;
+}