diff options
author | Kristian Lyngstol <kristian@bohemians.org> | 2016-03-11 12:03:25 +0100 |
---|---|---|
committer | Kristian Lyngstol <kristian@bohemians.org> | 2016-03-11 12:03:25 +0100 |
commit | d139059181888f85b1c3c0cd46e4812410eea8f5 (patch) | |
tree | ffd4003562e5a32454d0b8c944ed94bfe246575e | |
parent | 5b000365dd6ebbc9d1dc0b17c024cdc627289c5e (diff) |
NMS: Add (back) offset.
The use case is primarily about supporting generic ?offset=5m independently
from now=2015-04-02T15:00:30. Two reasons for this:
1. It allows easy generic client-side code to get two slightly offset time
series.
2. It makes it possible to get the most recent data + an offset without
having to refer to set now=(clock) to real time.
Also: Untested, so its probably broken.
-rwxr-xr-x | include/nms/web.pm | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/include/nms/web.pm b/include/nms/web.pm index d22a060..ddc1be0 100755 --- a/include/nms/web.pm +++ b/include/nms/web.pm @@ -58,6 +58,9 @@ sub setwhen { $now = db_safe_quote('now') . "::timestamp "; $cc{'max-age'} = "3600"; } + if (defined($get_params{'offset'})) { + $now = "(" . $now . " - " . db_safe_quote('offset') . "::interval)"; + } $when = " time > " . $now . " - '5m'::interval and time < " . $now . " "; return $when; } |