Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions queries/cdmq/cdm.js
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,7 @@ mSearch = async function (instance, index, yearDotMonth, termKeys, values, sourc
console.log(
'WARNING: the requested source for this query [' + source + '] does not exist in the returned data:\n'
);
console.log(JSON.stringify(obj.null, 2));
console.log(JSON.stringify(obj, null, 2));
return;
}
obj = obj[thisObj];
Expand Down Expand Up @@ -2314,7 +2314,7 @@ getIters = async function (
});

if (jsonArr.length > 0) {
var responses = esJsonArrRequest(instance, 'tag', '/_msearch', jsonArr);
var responses = await esJsonArrRequest(instance, 'tag', '/_msearch', jsonArr);
var runIds = [];
responses.forEach((response) => {
var theseRunIds = [];
Expand All @@ -2326,7 +2326,7 @@ getIters = async function (
var intersectedRunIds = intersectAllArrays(runIds);

if (jsonArr2.length > 0) {
var responses2 = esJsonArrRequest(instance, 'tag', '/_msearch', jsonArr2);
var responses2 = await esJsonArrRequest(instance, 'tag', '/_msearch', jsonArr2);
responses2.forEach((response) => {
response.hits.hits.forEach((run) => {
if (intersectedRunIds.includes(run._source.run['run-uuid'])) {
Expand Down Expand Up @@ -2378,8 +2378,7 @@ getIters = async function (

var iterIdsFromParam = [];
if (jsonArr.length > 0) {
var resp = esJsonArrRequest(instance, 'param', '/_msearch', jsonArr);
var responses = JSON.parse(resp.getBody());
var responses = await esJsonArrRequest(instance, 'param', '/_msearch', jsonArr);
var iterationIds = [];
responses.forEach((response) => {
var theseIterationIds = [];
Expand All @@ -2391,8 +2390,7 @@ getIters = async function (
iterIdsFromParam = intersectAllArrays(iterationIds);

if (jsonArr2 != '') {
var resp2 = esJsonArrRequest(instance, 'tag', '/_msearch', jsonArr2);
var responses2 = JSON.parse(resp2.getBody());
var responses2 = await esJsonArrRequest(instance, 'tag', '/_msearch', jsonArr2);
responses2.forEach((response) => {
response.hits.hits.forEach((hit) => {
if (iterIdsFromParam.includes(hit._source.iteration['iteration-uuid'])) {
Expand Down Expand Up @@ -2437,7 +2435,7 @@ getIters = async function (
}
});
}
if (isDefined(addIterations) && addRuns != []) {
if (isDefined(addIterations) && addIterations != []) {
addIterations.forEach((id) => {
if (!allIterIds.includes(id)) {
allIterIds.push(id);
Expand Down Expand Up @@ -2898,7 +2896,6 @@ mgetMetricIdsFromTerms = async function (instance, termsSets, yearDotMonth) {
') did not match number of requests (' +
totalReqs +
')';
retMsg = 'ERROR: mgetMetricIdsFromTerms(), terms[' + i + '] must have either a period-id or run-id';
retCode = 2;
return { 'metric-id-sets': metricIdsSets, 'ret-code': retCode, 'ret-msg': retMsg };
}
Expand Down Expand Up @@ -3542,7 +3539,7 @@ getMetricDataSets = async function (instance, sets, yearDotMonth) {
}
sets[i].end = periodRange.end;
} else {
retMag = 'ERROR: end is not defined or a period was not defined';
retMsg = 'ERROR: end is not defined or a period was not defined';
retCode = 2;
return { 'data-sets': [], 'ret-code': retCode, 'ret-msg': retMsg };
}
Expand Down Expand Up @@ -3608,7 +3605,7 @@ getMetricDataSets = async function (instance, sets, yearDotMonth) {

// Ensure that any breakouts are available for each set
for (var i = 0; i < sets.length; i++) {
if (sets[i].breakout != 'undefined') {
if (isDefined(sets[i].breakout)) {
for (var j = 0; j < sets[i].breakout.length; j++) {
var breakout = parseBreakoutEntry(sets[i].breakout[j]).name;
if (!setBreakouts[i].includes(breakout)) {
Expand Down
2 changes: 1 addition & 1 deletion queries/cdmq/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -1637,7 +1637,7 @@ app.post('/api/v1/metric-data', async (req, res) => {
error: resp['ret-msg']
});
}
metric_data = resp['data-sets'][0];
var metric_data = resp['data-sets'][0];

var labelCount = metric_data && metric_data.values ? Object.keys(metric_data.values).length : 0;
var elapsed = Date.now() - reqStart;
Expand Down
Loading