diff options
author | Kristian Lyngstol <kly@kly.no> | 2018-12-02 20:12:11 +0100 |
---|---|---|
committer | Kristian Lyngstol <kly@kly.no> | 2018-12-02 20:12:11 +0100 |
commit | efa1f777723289dcb2d61a4829adb549511731bc (patch) | |
tree | 8350df37677efe7e0420effcde07b112d31eca2d | |
parent | 7f5654c3fb0569ec984f163a06c7e53eefec8113 (diff) |
oplog: Add support fort "when"/dated replay
Makes the replay so much more "alive" :D
-rwxr-xr-x | web/api/read/oplog | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/web/api/read/oplog b/web/api/read/oplog index fb187ea..f2ed3a7 100755 --- a/web/api/read/oplog +++ b/web/api/read/oplog @@ -6,7 +6,14 @@ use nms::web; use strict; use warnings; -my $query = $nms::web::dbh->prepare('select id,date_trunc(\'second\',time) as timestamp,extract(hour from time) as h, extract(minute from time) as m,systems,username,log from oplog order by id desc;'); +my $filter = ''; + +if (defined($get_params{'now'})) { + $filter = "where time < timestamp with time zone 'epoch' + " . db_safe_quote('now') . " * INTERVAL '1 second' "; +} +my $query = $nms::web::dbh->prepare('select id,date_trunc(\'second\',time) as timestamp,extract(hour from time) as h, extract(minute from time) as m,systems,username,log from oplog ' + . $filter . +'order by id desc;'); $query->execute(); while (my $ref = $query->fetchrow_hashref()) { my %meh; |