Filter out past base events
This commit is contained in:
parent
a92c831bca
commit
8c1ac5f8cc
1 changed files with 40 additions and 34 deletions
|
@ -1,5 +1,5 @@
|
|||
import dateformat from 'dateformat';
|
||||
import baseevents from './c-base';
|
||||
import cbaseevents from './c-base';
|
||||
import '../elements/time';
|
||||
|
||||
function sortEvents(a, b) {
|
||||
|
@ -14,7 +14,15 @@ function sortEvents(a, b) {
|
|||
|
||||
function getEvents(number) {
|
||||
const now = new Date();
|
||||
return fetch('http://c-flo.cbrp3.c-base.org/35c3/fahrplan')
|
||||
return Promise.resolve(cbaseevents)
|
||||
.then(events => events.filter((e) => {
|
||||
const endDate = new Date(e.end);
|
||||
if (endDate < now) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}))
|
||||
.then(baseevents => fetch('http://c-flo.cbrp3.c-base.org/35c3/fahrplan')
|
||||
.then(res => res.json())
|
||||
.then((res) => {
|
||||
// res.schedule.conference.days[0].rooms.Adams[0]
|
||||
|
@ -46,9 +54,8 @@ function getEvents(number) {
|
|||
});
|
||||
});
|
||||
});
|
||||
return talks;
|
||||
})
|
||||
.then(talks => baseevents.concat(talks))
|
||||
.then(talks => baseevents.concat(talks)))
|
||||
.then(talks => fetch('https://launchlibrary.net/1.3/launch/next/2')
|
||||
.then(res => res.json())
|
||||
.then((res) => {
|
||||
|
@ -67,7 +74,6 @@ function getEvents(number) {
|
|||
return launches;
|
||||
})
|
||||
.then((launches) => {
|
||||
console.log(launches, talks);
|
||||
const allEvents = talks.concat(launches);
|
||||
allEvents.sort(sortEvents);
|
||||
return allEvents.slice(0, number);
|
||||
|
|
Loading…
Reference in a new issue