Skip to content

Commit

Permalink
simplified result.stats mapping in analyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcasalboni authored Feb 13, 2024
1 parent 9a69a51 commit 501d83d
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions lambda/analyzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ module.exports.handler = async(event, context) => {
const result = findOptimalConfiguration(event);

if (!!event.includeOutputResults) {
result.stats = removeTotalCostFromStats(event.stats);
// add stats to final result
result.stats = event.stats.map(stat => ({
value: stat.value,
averagePrice: stat.averagePrice,
averageDuration: stat.averageDuration,
// totalCost is omitted here
}));
}

return result;
Expand Down Expand Up @@ -141,12 +147,3 @@ const findBalanced = (stats, weight) => {
// just return the first one
return stats[0];
};

const removeTotalCostFromStats = (stats) => {
return stats
.map(stat => ({
value: stat.value,
averagePrice: stat.averagePrice,
averageDuration: stat.averageDuration
}));
}

0 comments on commit 501d83d

Please sign in to comment.