Skip to content

Commit

Permalink
Merge pull request #185 from Sean12697/master
Browse files Browse the repository at this point in the history
Filter Past Events
  • Loading branch information
Sean12697 authored May 5, 2022
2 parents 9b3f862 + ad79c69 commit 1b3aad7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions _data/dataGather.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class dataGather {
let eventsData = data.reduce((total, curr) => total.concat(curr[1]), []);
// Sorting / Filtering
let groups = this.sortNames(this.enhanceGroups(groupsData));
let events = this.sortTime(this.filterEvents(eventsData));
let events = this.sortTime(this.filterDuplicateEvents(this.filterPastEvents(eventsData)));
resolve([groups, events]);
})
});
Expand Down Expand Up @@ -86,13 +86,17 @@ class dataGather {
});
}

filterPastEvents(events) {
return events.filter(event => (new Date(event.startTimeISO) > (new Date())));
}

// https://stackoverflow.com/questions/2218999/remove-duplicates-from-an-array-of-objects-in-javascript
filterEvents(events) {
filterDuplicateEvents(events) {
return events.filter((event,index) => {
return index === events.findIndex(obj => {
return this.rtnLowercaseAlpha(event.name) == this.rtnLowercaseAlpha(obj.name) && this.formatDate(event.startTimeISO) == this.formatDate(obj.startTimeISO);
return this.rtnLowercaseAlpha(event.name) == this.rtnLowercaseAlpha(obj.name) && this.formatDate(event.startTimeISO) == this.formatDate(obj.startTimeISO);
});
});
});
}

rtnLowercaseAlpha(string) {
Expand Down
2 changes: 1 addition & 1 deletion _data/groupDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -594,5 +594,5 @@ module.exports = [{
links: [{
link: "http://www.soda-social.com/",
type: "Website"
}]
}]
}]

0 comments on commit 1b3aad7

Please sign in to comment.