Filter out past base events

This commit is contained in:
Henri Bergius 2018-12-25 01:18:53 +01:00
parent a92c831bca
commit 8c1ac5f8cc

View file

@ -1,5 +1,5 @@
import dateformat from 'dateformat'; import dateformat from 'dateformat';
import baseevents from './c-base'; import cbaseevents from './c-base';
import '../elements/time'; import '../elements/time';
function sortEvents(a, b) { function sortEvents(a, b) {
@ -14,7 +14,15 @@ function sortEvents(a, b) {
function getEvents(number) { function getEvents(number) {
const now = new Date(); 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.json())
.then((res) => { .then((res) => {
// res.schedule.conference.days[0].rooms.Adams[0] // 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(talks => fetch('https://launchlibrary.net/1.3/launch/next/2')
.then(res => res.json()) .then(res => res.json())
.then((res) => { .then((res) => {
@ -67,7 +74,6 @@ function getEvents(number) {
return launches; return launches;
}) })
.then((launches) => { .then((launches) => {
console.log(launches, talks);
const allEvents = talks.concat(launches); const allEvents = talks.concat(launches);
allEvents.sort(sortEvents); allEvents.sort(sortEvents);
return allEvents.slice(0, number); return allEvents.slice(0, number);