redis-time-series-ts
Version:
Javascript RedisTimeSeries client
31 lines (30 loc) • 1.03 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.MultiGetResponseRender = void 0;
const label_1 = require("../entity/label");
const sample_1 = require("../entity/sample");
class MultiGetResponseRender {
render(response) {
const ranges = [];
for (const bucket of response) {
const key = bucket[0];
const labels = [];
for (const label of bucket[1]) {
labels.push(new label_1.Label(label[0], label[1]));
}
let sampleValue = "0";
let sampleTimestamp = 0;
if (bucket[2].length !== 0) {
sampleValue = bucket[2][1];
sampleTimestamp = bucket[2][0];
}
ranges.push({
key: key,
labels: labels,
data: new sample_1.Sample(key, Number(sampleValue), sampleTimestamp)
});
}
return ranges;
}
}
exports.MultiGetResponseRender = MultiGetResponseRender;