Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const data: DataFrame[] = [];
if (!result || !result.data) {
return { data };
}
// Series are either at the root or under a node called 'series'
const series = result.data.series || result.data;
if (!_.isArray(series)) {
throw { message: 'Missing series in result', data: result };
}
for (let i = 0; i < series.length; i++) {
const s = series[i];
for (let y = 0; y < s.datapoints.length; y++) {
s.datapoints[y][1] *= 1000;
}
const frame = toDataFrame(s);
// Metrictank metadata
if (s.meta) {
frame.meta = {
datasource: this.name,
custom: {
request: result.data.meta, // info for the whole request
info: s.meta, // Array of metadata
},
};
}
data.push(frame);
}
return { data };
};
export function getProcessedDataFrames(results?: DataQueryResponseData[]): DataFrame[] {
if (!isArray(results)) {
return [];
}
const dataFrames: DataFrame[] = [];
for (const result of results) {
const dataFrame = guessFieldTypes(toDataFrame(result));
// clear out any cached calcs
for (const field of dataFrame.fields) {
field.calcs = null;
}
dataFrames.push(dataFrame);
}
return dataFrames;
}
dataFrame.push(series);
}
if (response.aggregations) {
const aggregations = response.aggregations;
const target = this.targets[n];
const tmpSeriesList: any[] = [];
const table = new TableModel();
this.processBuckets(aggregations, target, tmpSeriesList, table, {}, 0);
this.trimDatapoints(tmpSeriesList, target);
this.nameSeries(tmpSeriesList, target);
for (let y = 0; y < tmpSeriesList.length; y++) {
const series = toDataFrame(tmpSeriesList[y]);
dataFrame.push(series);
}
}
}
return { data: dataFrame };
}
}
...queryResult.series.map(({ name, points }: any) => {
const dataFrame = toDataFrame({
target: name,
datapoints: points,
refId: queryRequest.refId,
meta: queryResult.meta,
});
if (link) {
for (const field of dataFrame.fields) {
field.config.links = [
{
url: link,
title: 'View in CloudWatch console',
targetBlank: true,
},
];
}
}
response.series = response.legacy.map(v => toDataFrame(v));
}
queryRes.series.forEach((series: any) => {
const timeSerie: TimeSeries = {
target: series.name,
datapoints: series.points,
refId: queryRes.refId,
meta: queryRes.meta,
};
result.push(toDataFrame(timeSerie));
});
});
export function getProcessedDataFrames(results?: DataQueryResponseData[]): DataFrame[] {
if (!isArray(results)) {
return [];
}
const series: DataFrame[] = [];
for (const r of results) {
if (r) {
series.push(guessFieldTypes(toDataFrame(r)));
}
}
return series;
}
...queryResult.series.map(({ name, points }: any) => {
const dataFrame = toDataFrame({
target: name,
datapoints: points,
refId: queryRequest.refId,
meta: queryResult.meta,
});
if (link) {
for (const field of dataFrame.fields) {
field.config.links = [
{
url: link,
title: 'View in CloudWatch console',
targetBlank: true,
},
];
}
}
dataFrame.push(series);
}
if (response.aggregations) {
const aggregations = response.aggregations;
const target = this.targets[n];
const tmpSeriesList: any[] = [];
const table = new TableModel();
this.processBuckets(aggregations, target, tmpSeriesList, table, {}, 0);
this.trimDatapoints(tmpSeriesList, target);
this.nameSeries(tmpSeriesList, target);
for (let y = 0; y < tmpSeriesList.length; y++) {
const series = toDataFrame(tmpSeriesList[y]);
dataFrame.push(series);
}
}
}
return { data: dataFrame };
}
}