Skip to content

Commit

Permalink
restoring artist date filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
sam9116 committed May 11, 2024
1 parent 208fdbb commit f0d04d4
Showing 1 changed file with 27 additions and 21 deletions.
48 changes: 27 additions & 21 deletions src/BaseInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,35 +172,41 @@ const BaseInput = forwardRef(({ setConcerts, setUserLocation, setMapStyle, start
return (distancea - distanceb);
})

//filter part one concert
console.log(`filter the sorted concert by artist name, so we're only left with one concert per artist`);
var onenewConcerts = incomingAllConcerts.filter((value, index, self) => {
return self.findIndex(v => v.artist === value.artist || v.title === value.title) === index;
});
if (!isChecked) {
//filter part one concert
console.log(`filter the sorted concert by artist name, so we're only left with one concert per artist`);
incomingAllConcerts = incomingAllConcerts.filter((value, index, self) => {
return self.findIndex(v => v.artist === value.artist || v.title === value.title) === index;
});
}


//filter part all concert
console.log(`filter the sorted concert by artist name`);
var newConcerts = incomingAllConcerts

// filter the concert list by
// if artist name is included in titles of concerts performed by other artists
if (concerts.length > 0) {
newConcerts = newConcerts.filter((concert) => {
if (!isChecked) {
if (concerts.length > 0) {
newConcerts = newConcerts.filter((concert) => {

var match = true;
var matchindex = newConcerts.findIndex((findConcert) => {
return findConcert.title.includes(concert.artist) && (findConcert.artist !== concert.artist);
})
var match = true;
var matchindex = newConcerts.findIndex((findConcert) => {
return findConcert.title.includes(concert.artist) && (findConcert.artist !== concert.artist);
})

if (matchindex !== -1) {
alert(`${concert.artist} is performing as part of ${newConcerts[matchindex].title} by ${newConcerts[matchindex].artist}, consolidating schedule`);
match = false;
}
if (matchindex !== -1) {
alert(`${concert.artist} is performing as part of ${newConcerts[matchindex].title} by ${newConcerts[matchindex].artist}, consolidating schedule`);
match = false;
}

return match;
return match;

});
});
}
}

newConcerts = newConcerts.sort((a, b) => { return (new Date(a.date) - new Date(b.date)) });
console.log(`concat the new concerts into the optimized list`);
setConcerts(newConcerts);
Expand Down Expand Up @@ -243,10 +249,10 @@ const BaseInput = forwardRef(({ setConcerts, setUserLocation, setMapStyle, start
},
}}
label="Enter Artist Name:"
value={artistName} onChange={(e) =>{
setArtistName(e.target.value);
updateArtistNameInParent(e.target.value);
}}
value={artistName} onChange={(e) => {
setArtistName(e.target.value);
updateArtistNameInParent(e.target.value);
}}
/>
<Button
type="submit"
Expand Down

0 comments on commit f0d04d4

Please sign in to comment.