Skip to content

Commit

Permalink
fix eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
fewieden committed Apr 23, 2022
1 parent 12a7d63 commit 82f2144
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions apis/autoblog.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,12 @@ async function getAllStations() {
* @function mergePrices
* @description Merges fuel prices of different types of gas station
*
* @param {Object[]} responses - List of gas stations with prices of single fuel type.
*
* @returns {Object} Returns gas stations with merged prices and max prices per fuel type.
*/
function mergePrices(responses) {
const {indexedStations, maxPricesByType} = responses.reduce(({indexedStations, maxPricesByType}, station) => {
const { indexedStations, maxPricesByType } = responses.reduce(({ indexedStations, maxPricesByType }, station) => {
const stationKey = `${station.name}-${station.address}`;

if (!indexedStations[stationKey]) {
Expand All @@ -179,10 +181,10 @@ function mergePrices(responses) {
maxPricesByType[station.fuelType] = station.prices[station.fuelType];
}

return {indexedStations, maxPricesByType};
}, {indexedStations: {}, maxPricesByType: {}});
return { indexedStations, maxPricesByType };
}, { indexedStations: {}, maxPricesByType: {} });

return {stations: Object.values(indexedStations), maxPricesByType};
return { stations: Object.values(indexedStations), maxPricesByType };
}

/**
Expand All @@ -197,13 +199,13 @@ function mergePrices(responses) {
async function getData() {
const responses = await getAllStations();

let {stations, maxPricesByType} = mergePrices(responses);
const { stations, maxPricesByType } = mergePrices(responses);

stations.forEach(station => fillMissingPrices(station, maxPricesByType));

stations = stations.filter(station => station.distance <= config.radius);
const filteredStations = stations.filter(station => station.distance <= config.radius);

const stationsSortedByDistance = stations.sort((a, b) => a.distance - b.distance);
const stationsSortedByDistance = filteredStations.sort((a, b) => a.distance - b.distance);
const stationsSortedByPrice = [...stationsSortedByDistance].sort(sortByPrice);

return {
Expand Down

0 comments on commit 82f2144

Please sign in to comment.