Skip to content

Commit

Permalink
#74 avoiding overflow talks in speaker lineup talks
Browse files Browse the repository at this point in the history
  • Loading branch information
fcamblor committed Oct 31, 2024
1 parent eb90111 commit 1247f0b
Showing 1 changed file with 27 additions and 25 deletions.
52 changes: 27 additions & 25 deletions cloud/functions/src/models/Event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,35 @@ export type FullEvent = {

export function detailedTalksToSpeakersLineup(talks: DetailedTalk[]): LineupSpeaker[] {
return talks.reduce((speakers, talk) => {
talk.speakers.forEach(speaker => {
const lineupSpeaker = match(speakers.find(lineupSpeaker => lineupSpeaker.id === speaker.id))
.with(P.not(P.nullish), lineupSpeaker => lineupSpeaker)
.otherwise(() => {
const newLineupSpeaker: LineupSpeaker = {
...speaker,
talks: []
}
speakers.push(newLineupSpeaker);
return newLineupSpeaker;
})
if(!talk.isOverflow) {
talk.speakers.forEach(speaker => {
const lineupSpeaker = match(speakers.find(lineupSpeaker => lineupSpeaker.id === speaker.id))
.with(P.not(P.nullish), lineupSpeaker => lineupSpeaker)
.otherwise(() => {
const newLineupSpeaker: LineupSpeaker = {
...speaker,
talks: []
}
speakers.push(newLineupSpeaker);
return newLineupSpeaker;
})

lineupSpeaker.talks.push({
id: talk.id,
title: talk.title,
format: talk.format,
language: talk.language,
track: talk.track,
tags: talk.tags,
allocation: {
room: talk.room,
start: talk.start,
end: talk.end,
},
otherSpeakers: talk.speakers.filter(sp => sp.id !== speaker.id),
lineupSpeaker.talks.push({
id: talk.id,
title: talk.title,
format: talk.format,
language: talk.language,
track: talk.track,
tags: talk.tags,
allocation: {
room: talk.room,
start: talk.start,
end: talk.end,
},
otherSpeakers: talk.speakers.filter(sp => sp.id !== speaker.id),
})
})
})
}
return speakers;
}, [] as LineupSpeaker[])
}

0 comments on commit 1247f0b

Please sign in to comment.