Skip to content

Commit

Permalink
add past speakers info
Browse files Browse the repository at this point in the history
  • Loading branch information
McFrid committed Dec 16, 2024
1 parent 0b897ce commit 0b11dee
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@focus-reactive/graphql-content-layer",
"version": "3.2.1",
"version": "3.2.2",
"private": false,
"main": "dist/index.js",
"scripts": {
Expand Down
49 changes: 35 additions & 14 deletions src/fetch-speakers.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { prepareSpeakers, trySelectSettings, sortByOrder } = require('./utils');
const { speakerInfoFragment, sponsorLogoFragment } = require('./fragments');
const dayjs = require('dayjs');
const { getSpeakers } = require('./http-utils');
const { getSpeakers, getPastSpeakers } = require('./http-utils');

const selectSettings = trySelectSettings(
s => ({
Expand Down Expand Up @@ -145,17 +145,43 @@ const fetchData = async (client, { tagColors, labelColors, ...vars }) => {
emsEventId: res.conf.year[0].emsEventId,
useEmsData: res.conf.year[0].useEmsData,
}));
const emsSpeakers = data.useEmsData && (await getSpeakers(data.emsEventId));

let emsSpeakers, pastSpeakers;
if (data.useEmsData) {
[emsSpeakers, pastSpeakers] = await Promise.all([
getSpeakers(data.emsEventId),
getPastSpeakers(data.emsEventId),
]);
}

const { openForTalks } = data;

const convertDateToIso = item => ({
...item,
timeString: item.timeString ? dayjs(item.timeString).toISOString() : null,
});
const [
{ daySpeakers, eveningSpeakers },
{ daySpeakers: daySpeakersPast, eveningSpeakers: eveningSpeakersPast },
] = await Promise.all([emsSpeakers || data.speakers, pastSpeakers].map(speakers =>
processSpeakers(speakers, tagColors, labelColors)
));

return {
speakers: { main: daySpeakers },
eveningSpeakers,
pastSpeakers: {
main: daySpeakersPast,
eveningSpeakers: eveningSpeakersPast,
},
speakersBtn: openForTalks ? 'CALL FOR SPEAKERS' : false,
labelColors,
};
};

const convertDateToIso = item => ({
...item,
timeString: item.timeString ? dayjs(item.timeString).toISOString() : null,
});

const speakersRaw = emsSpeakers || data.speakers;
const speakersWithPlainActivities = speakersRaw.map(speaker => {
const processSpeakers = async (rawSpeakers, tagColors, labelColors) => {
const speakersWithPlainActivities = rawSpeakers.map(speaker => {
if (!speaker.activities) {
console.log('invalid activities', JSON.stringify(speaker));
}
Expand Down Expand Up @@ -214,12 +240,7 @@ const fetchData = async (client, { tagColors, labelColors, ...vars }) => {
({ isNightSpeaker }) => isNightSpeaker,
);

return {
speakers: { main: daySpeakers },
eveningSpeakers,
speakersBtn: openForTalks ? 'CALL FOR SPEAKERS' : false,
labelColors,
};
return { daySpeakers, eveningSpeakers };
};

module.exports = {
Expand Down
2 changes: 2 additions & 0 deletions src/http-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const baseEventFetch = path => {
};

const getSpeakers = baseEventFetch('speakers');
const getPastSpeakers = baseEventFetch('speakers/past');
const getPartners = baseEventFetch('partners');
const getTopSpeaker = baseEventFetch('speakers/top');
const getSchedule = baseEventFetch('schedule');
Expand All @@ -29,6 +30,7 @@ const getEvent = baseEventFetch('');

module.exports = {
getSpeakers,
getPastSpeakers,
getPartners,
getSchedule,
getTopSpeaker,
Expand Down

0 comments on commit 0b11dee

Please sign in to comment.