@cryptotaxi247 / netdata-1 / commits / 2f7ca96af

API parameter "after" is now relative to "before" and defaults to -update_every (minus update every)

Costa Tsaousis (ktsaou) committed Jun 5, 2016 at 16:09 UTC 2f7ca96afb435ef787a5c44d8ec847b7dc9a0c75
2 files changed +6 -5
src/rrd2json.c
+5 -4
@@ -1230,7 +1230,7 @@ RRDR *rrd2rrdr(RRDSET *st, long points, long long after, long long before, int g
1230 int absolute_period_requested = -1;
1231
1232 time_t first_entry_t = rrdset_first_entry_t(st);
1233 - time_t last_entry_t = rrdset_last_entry_t(st);
1233 + time_t last_entry_t = rrdset_last_entry_t(st);
1234
1235 if(before == 0 && after == 0) {
1236 before = last_entry_t;
@@ -1239,13 +1239,14 @@ RRDR *rrd2rrdr(RRDSET *st, long points, long long after, long long before, int g
1239 }
1240
1241 // allow relative for before and after
1242 - if(before <= st->update_every * st->entries) {
1242 + if(((before < 0)?-before:before) <= (st->update_every * st->entries)) {
1243 before = last_entry_t + before;
1244 absolute_period_requested = 0;
1245 }
1246
1247 - if(after <= st->update_every * st->entries) {
1248 - after = last_entry_t + after;
1247 + if(((after < 0)?-after:after) <= (st->update_every * st->entries)) {
1248 + if(after == 0) after = -st->update_every;
1249 + after = before + after;
1250 absolute_period_requested = 0;
1251 }
1252
web/netdata-swagger.yaml
+1 -1
@@ -66,7 +66,7 @@ paths:
66 allowEmptyValue: false
67 - name: after
68 in: query
69 - 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.'
69 + 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.'
70 required: true
71 type: number
72 format: integer