Skip to content

Commit

Permalink
Timeseries Visual Builder - DST shift in historic data (#34283) (#34777)
Browse files Browse the repository at this point in the history
* Timeseries Visual Builder - DST shift in historic data

* Timeseries Visual Builder - DST shift in historic data - performance optimization
  • Loading branch information
alexwizp committed Apr 9, 2019
1 parent 2954b57 commit 20a0f00
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,23 @@ export default function timeShift(resp, panel, series) {
return next => results => {
if (/^([+-]?[\d]+)([shmdwMy]|ms)$/.test(series.offset_time)) {
const matches = series.offset_time.match(/^([+-]?[\d]+)([shmdwMy]|ms)$/);

if (matches) {
const offsetValue = matches[1];
const offsetValue = Number(matches[1]);
const offsetUnit = matches[2];
const offset = moment.duration(offsetValue, offsetUnit).valueOf();

results.forEach(item => {
if (_.startsWith(item.id, series.id)) {
item.data = item.data.map(row => [moment(row[0]).add(offsetValue, offsetUnit).valueOf(), row[1]]);
item.data = item.data.map(([time, value]) => [
time + offset,
value
]);
}
});
}
}

return next(results);
};
}

0 comments on commit 20a0f00

Please sign in to comment.