]> arthur.barton.de Git - netdata.git/commitdiff
API parameter "after" is now relative to "before" and defaults to -update_every ...
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Sun, 5 Jun 2016 13:09:34 +0000 (16:09 +0300)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Sun, 5 Jun 2016 13:09:34 +0000 (16:09 +0300)
src/rrd2json.c
web/netdata-swagger.yaml

index 361479285812a27103a8c9f49037c8eb3ace6e3b..905e699e03e85c605fec292c88ae18b4971437d8 100644 (file)
@@ -1230,7 +1230,7 @@ RRDR *rrd2rrdr(RRDSET *st, long points, long long after, long long before, int g
        int absolute_period_requested = -1;
 
        time_t first_entry_t = rrdset_first_entry_t(st);
-       time_t last_entry_t = rrdset_last_entry_t(st);
+       time_t last_entry_t  = rrdset_last_entry_t(st);
 
        if(before == 0 && after == 0) {
                before = last_entry_t;
@@ -1239,13 +1239,14 @@ RRDR *rrd2rrdr(RRDSET *st, long points, long long after, long long before, int g
        }
 
        // allow relative for before and after
-       if(before <= st->update_every * st->entries) {
+       if(((before < 0)?-before:before) <= (st->update_every * st->entries)) {
                before = last_entry_t + before;
                absolute_period_requested = 0;
        }
 
-       if(after <= st->update_every * st->entries) {
-               after = last_entry_t + after;
+       if(((after < 0)?-after:after) <= (st->update_every * st->entries)) {
+               if(after == 0) after = -st->update_every;
+               after = before + after;
                absolute_period_requested = 0;
        }
 
index 2a80d4cd923155bc3b44cb4586936d3ddcb5ece4..167dd8baccbc19ca946126120aed287c47fb2671 100644 (file)
@@ -66,7 +66,7 @@ paths:
           allowEmptyValue: false
         - name: after
           in: query
-          description: 'This parameter can either be an absolute timestamp specifying the starting point of the data to be returned, or a relative number of seconds, to the last collected timestamp. Netdata will assume it is a relative number if it is smaller than the duration of the round robin database for this chart. So, if the round robin database is 3600 seconds, any value from -3600 to 3600 will trigger relative arithmetics. Netdata will adapt this parameter to the boundaries of the round robin database.'
+          description: 'This parameter can either be an absolute timestamp specifying the starting point of the data to be returned, or a relative number of seconds (relative to parameter: before). Netdata will assume it is a relative number if it is smaller than the duration of the round robin database for this chart. So, if the round robin database is 3600 seconds, any value from -3600 to 3600 will trigger relative arithmetics. Netdata will adapt this parameter to the boundaries of the round robin database.'
           required: true
           type: number
           format: integer