Skip to content

Commit

Permalink
filter concerts by date... so user will not be attending two concerts…
Browse files Browse the repository at this point in the history
… on the same date across the coutnry
  • Loading branch information
sam9116 committed Feb 11, 2024
1 parent 4de1757 commit 128c18b
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/BaseInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,24 @@ const BaseInput = forwardRef(({ setConcerts, setUserLocation, setMapStyle, start
return (distancea - distanceb);
})

console.log(`filter the sorted concert by artist name, so we're only left with one concert per artist`);
console.log(`filter the sorted concert by date , so we're only left with no more than 1 concert on the same date `);
var newConcerts = incomingAllConcerts.filter((value, index, self) => {
return self.findIndex((v) => {

var vDate = new Date(v.date).toDateString();
var valueDate = new Date(value.date).toDateString();

return vDate.valueOf() == valueDate.valueOf();
}) === index;
});

console.log(`filter the sorted concert by artist name, so we're only left with one concert per artist`);
newConcerts = newConcerts.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`);
console.log(`concat the new concerts into the optimized list`);
setConcerts(newConcerts);
}
return (
Expand Down

0 comments on commit 128c18b

Please sign in to comment.