Skip to content

Commit

Permalink
optimizing concerts by least distance traveled, and sorted by time....
Browse files Browse the repository at this point in the history
  • Loading branch information
sam9116 committed Feb 4, 2024
1 parent 58c49e1 commit 2140022
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/BaseInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,14 @@ const BaseInput = forwardRef(({ setConcerts, setUserLocation, setMapStyle, start
var distanceb = distanceInKmBetweenEarthCoordinates(originPoint.latitude, originPoint.longitude, b.location.latitude, b.location.longitude);
console.log(`distancea: ${distancea}`);
console.log(`distanceb: ${distanceb}`);
return (new Date(a.date) - new Date(b.date)) || (distancea - distanceb);
return (new Date(a.date) - new Date(b.date)) && (distancea - distanceb);
});

console.log(`filter the sorted concert by artist name, so we're only left with one concert per artist`);
var newConcerts = sortedAllConcerts.filter((value, index, self) => {
return self.findIndex(v => v.artist === value.artist) === index;
})

newConcerts = newConcerts.sort((a, b)=>{return (new Date(a.date) - new Date(b.date))});
console.log(`concat the new concerts into the optimized`);
setConcerts(newConcerts);
}
Expand Down

0 comments on commit 2140022

Please sign in to comment.