diff --git a/new.pl b/new.pl index 6652bf2..3f9e678 100755 --- a/new.pl +++ b/new.pl @@ -26,11 +26,16 @@ sub newer($$) { } my $setlastrecord = $db->prepare("REPLACE INTO lastrecord (id, timestamp) VALUES (?, ?)") or die $db->errstr; -sub setlastrecord($$) { - my ($id, $time) = @_; +my $recordlevel = $db->prepare("INSERT INTO levels (stationid, timestamp, level) VALUES (?,?,?)") or die $db->errstr; +sub recordlevel($$$) { + my ($id, $time, $level) = @_; + $recordlevel->execute($id, $time, $level); $setlastrecord->execute($id, $time); + } +my $rememberstation = $db->prepare("INSERT INTO stations (id, name, watercourse, datum) VALUES (?,?,?,?)") or die $db->errstr; + # First thing on the line should be the current time print time, "\t" unless $ENV{R_GPLOT}; @@ -43,7 +48,9 @@ foreach my $station (@stations) { my $level; my $stationname; my $lastupdate; - if ($res->is_success) { + my $watercourse; + my $datum; + if ($res->is_success and $res->content =~ m~Current level:~) { $res->content =~ m~