Skip to content

Commit

Permalink
Change forEach to map
Browse files Browse the repository at this point in the history
  • Loading branch information
jen-huang committed Apr 23, 2020
1 parent f05b6ad commit 0bbc12f
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@ export const getListHandler: RequestHandler = async (context, request, response)
},
});

const dataStreams: DataStream[] = [];

(indexResults as any[]).forEach(result => {
const dataStreams: DataStream[] = (indexResults as any[]).map(result => {
const {
key: indexName,
dataset: { buckets: datasetBuckets },
Expand All @@ -101,15 +99,15 @@ export const getListHandler: RequestHandler = async (context, request, response)
package: { buckets: packageBuckets },
last_activity: { value_as_string: lastActivity },
} = result;
dataStreams.push({
return {
index: indexName,
dataset: datasetBuckets.length ? datasetBuckets[0].key : '',
namespace: namespaceBuckets.length ? namespaceBuckets[0].key : '',
type: typeBuckets.length ? typeBuckets[0].key : '',
package: packageBuckets.length ? packageBuckets[0].key : '',
last_activity: lastActivity,
size_in_bytes: indexStats[indexName] ? indexStats[indexName].total.store.size_in_bytes : 0,
});
};
});

const body: GetDataStreamsResponse = {
Expand Down

0 comments on commit 0bbc12f

Please sign in to comment.