Skip to content
This repository has been archived by the owner on Aug 9, 2022. It is now read-only.

Commit

Permalink
fix column issue in csv reports (#293)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongnansu committed Jan 8, 2021
1 parent 71d1498 commit 45c1498
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions kibana-reports/server/routes/utils/dataReportHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,16 @@ export var metaData = {

// Get the selected columns by the user.
export const getSelectedFields = async (columns) => {
const selectedFields = [];
for (let column of columns) {
if (column !== '_source') {
metaData.fields_exist = true;
metaData.selectedFields.push(column);
selectedFields.push(column);
} else {
metaData.selectedFields.push('_source');
selectedFields.push('_source');
}
}
metaData.selectedFields = selectedFields;
};

//Build the ES query from the meta data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,13 @@ async function populateMetaData(
(metaData.timeFieldName = resIndexPattern.timeFieldName),
(metaData.fields = resIndexPattern.fields); // Get all fields
// Getting fields of type Date
const dateFields = [];
for (const item of JSON.parse(metaData.fields)) {
if (item.type === 'date') {
metaData.dateFields.push(item.name);
dateFields.push(item.name);
}
}
metaData.dateFields = dateFields;
}
}
}
Expand Down

0 comments on commit 45c1498

Please sign in to comment.