Skip to content

Commit

Permalink
#74 introduced FullEvent.lineupSpeakers aimed at being able to list s…
Browse files Browse the repository at this point in the history
…peakers even when we don't have any schedule yet
  • Loading branch information
fcamblor committed Aug 30, 2024
1 parent 4ac36a0 commit c88deee
Show file tree
Hide file tree
Showing 12 changed files with 103 additions and 33 deletions.
3 changes: 2 additions & 1 deletion cloud/functions/src/crawlers/bdxio/crawler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {z} from "zod";
import {FullEvent} from "../../models/Event";
import {detailedTalksToSpeakersLineup, FullEvent} from "../../models/Event";
import {
BreakTimeSlot,
DailySchedule, DetailedTalk, Room, ScheduleTimeSlot,
Expand Down Expand Up @@ -360,6 +360,7 @@ export const BDXIO_CRAWLER: CrawlerKind<typeof BDXIO_PARSER> = {
conferenceDescriptor: confDescriptor,
daySchedules: dailySchedules,
talks: detailedTalks,
lineupSpeakers: detailedTalksToSpeakersLineup(detailedTalks),
};

return fullEvent;
Expand Down
3 changes: 2 additions & 1 deletion cloud/functions/src/crawlers/camping-des-speakers/crawler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {z} from "zod";
import {FullEvent} from "../../models/Event";
import {detailedTalksToSpeakersLineup, FullEvent} from "../../models/Event";
import {
BreakTimeSlot,
DailySchedule, DetailedTalk, ScheduleTimeSlot,
Expand Down Expand Up @@ -268,6 +268,7 @@ export const CAMPING_DES_SPEAKERS_CRAWLER: CrawlerKind<typeof CAMPING_DES_SPEAKE
conferenceDescriptor: confDescriptor,
daySchedules: dailySchedules,
talks: detailedTalks,
lineupSpeakers: detailedTalksToSpeakersLineup(detailedTalks),
};

return fullEvent;
Expand Down
3 changes: 2 additions & 1 deletion cloud/functions/src/crawlers/codeurs-en-seine/crawler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {z} from "zod";
import {FullEvent} from "../../models/Event";
import {detailedTalksToSpeakersLineup, FullEvent} from "../../models/Event";
import {
Break, BreakTimeSlot, DailySchedule,
DetailedTalk, ScheduleTimeSlot, SocialLink, Speaker, Talk, TalksTimeSlot
Expand Down Expand Up @@ -282,6 +282,7 @@ export const CODEURS_EN_SEINE_CRAWLER: CrawlerKind<typeof CODEURS_EN_SEINE_PARSE
conferenceDescriptor: confDescriptor,
daySchedules: dailySchedules,
talks: detailedTalks,
lineupSpeakers: detailedTalksToSpeakersLineup(detailedTalks),
};

return fullEvent;
Expand Down
5 changes: 3 additions & 2 deletions cloud/functions/src/crawlers/devoxx-scala/crawler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
ThemedTalkFormat,
ThemedTrack
} from "../../../../../shared/daily-schedule.firestore"
import {FullEvent} from "../../models/Event";
import {detailedTalksToSpeakersLineup, FullEvent} from "../../models/Event";
import {ISODatetime} from "../../../../../shared/type-utils";
import {Temporal} from "@js-temporal/polyfill";
import {z} from "zod";
Expand Down Expand Up @@ -300,7 +300,8 @@ export const DEVOXX_SCALA_CRAWLER: CrawlerKind<typeof DEVOXX_SCALA_DESCRIPTOR_PA

const event: FullEvent = {
id: eventId, info: eventInfo, daySchedules: dailySchedules,
talks, conferenceDescriptor: eventDescriptor
talks, conferenceDescriptor: eventDescriptor,
lineupSpeakers: detailedTalksToSpeakersLineup(talks),
}
return event
}
Expand Down
5 changes: 3 additions & 2 deletions cloud/functions/src/crawlers/devoxx/crawler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
Speaker,
Talk
} from "../../../../../shared/daily-schedule.firestore"
import { FullEvent } from "../../models/Event";
import {detailedTalksToSpeakersLineup, FullEvent} from "../../models/Event";
import { ISODatetime, ISOLocalDate } from "../../../../../shared/type-utils";
import { Day, ListableEvent } from "../../../../../shared/event-list.firestore";
import { Temporal } from "@js-temporal/polyfill";
Expand Down Expand Up @@ -153,7 +153,8 @@ export const DEVOXX_CRAWLER: CrawlerKind<typeof DEVOXX_DESCRIPTOR_PARSER> = {

const event: FullEvent = {
id: eventId, info: eventInfo, daySchedules,
talks: eventTalks, conferenceDescriptor: eventDescriptor
talks: eventTalks, conferenceDescriptor: eventDescriptor,
lineupSpeakers: detailedTalksToSpeakersLineup(eventTalks),
}
return event
}
Expand Down
3 changes: 2 additions & 1 deletion cloud/functions/src/crawlers/jugsummercamp/crawler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {z} from "zod";
import {FullEvent} from "../../models/Event";
import {detailedTalksToSpeakersLineup, FullEvent} from "../../models/Event";
import {
BreakTimeSlot,
DailySchedule, DetailedTalk, ScheduleTimeSlot,
Expand Down Expand Up @@ -258,6 +258,7 @@ export const JUG_SUMMERCAMP_CRAWLER: CrawlerKind<typeof JUG_SUMMERCAMP_PARSER> =
conferenceDescriptor: confDescriptor,
daySchedules: dailySchedules,
talks: detailedTalks,
lineupSpeakers: detailedTalksToSpeakersLineup(detailedTalks),
};

return fullEvent;
Expand Down
3 changes: 2 additions & 1 deletion cloud/functions/src/crawlers/la-product-conf/crawler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {z} from "zod";
import {FullEvent} from "../../models/Event";
import {detailedTalksToSpeakersLineup, FullEvent} from "../../models/Event";
import {ISODatetime, ISOLocalDate} from "../../../../../shared/type-utils";
import {Temporal} from "@js-temporal/polyfill";
import {
Expand Down Expand Up @@ -286,6 +286,7 @@ export const LA_PRODUCT_CONF_CRAWLER: CrawlerKind<typeof LA_PRODUCT_CONF_DESCRIP
conferenceDescriptor: confDescriptor,
daySchedules: [{ day: LOCAL_DATE, timeSlots }],
talks,
lineupSpeakers: detailedTalksToSpeakersLineup(talks),
};

return fullEvent;
Expand Down
5 changes: 3 additions & 2 deletions cloud/functions/src/crawlers/openplanner/crawler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {BreakTimeslotWithPotentiallyUnknownIcon, FullEvent} from "../../models/Event";
import {BreakTimeslotWithPotentiallyUnknownIcon, detailedTalksToSpeakersLineup, FullEvent} from "../../models/Event";
import {z} from "zod";
import {EVENT_DESCRIPTOR_PARSER, EVENT_FEATURES_CONFIG_PARSER, RATINGS_CONFIG_PARSER} from "../crawler-parsers";
import {CrawlerKind, TALK_TRACK_FALLBACK_COLORS} from "../crawl";
Expand Down Expand Up @@ -293,7 +293,8 @@ export const OPENPLANNER_CRAWLER: CrawlerKind<typeof OPENPLANNER_DESCRIPTOR_PARS
location: descriptor.location,
theming: openPlannerSchedule.theming,
keywords: descriptor.keywords
}
},
lineupSpeakers: detailedTalksToSpeakersLineup(talks),
}

return event
Expand Down
41 changes: 22 additions & 19 deletions cloud/functions/src/crawlers/single-file/crawler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {FullEvent} from "../../models/Event";
import {detailedTalksToSpeakersLineup, FullEvent} from "../../models/Event";
import {z} from "zod";
import {
BREAK_PARSER,
Expand Down Expand Up @@ -119,27 +119,29 @@ export const SINGLE_FILE_CRAWLER: CrawlerKind<typeof SINGLE_FILE_DESCRIPTOR_PARS
timeSlots: timeslots.filter(timeslot => timeslot.start.startsWith(day.localDate))
}))

const talks = descriptor.talks.map(detailedTalk => ({
start: detailedTalk.start,
end: detailedTalk.end,
summary: detailedTalk.summary,
description: detailedTalk.summary,
tags: detailedTalk.tags,
assets: detailedTalk.assets,
speakers: detailedTalk.speakers,
id: detailedTalk.id,
title: detailedTalk.title,
isOverflow: detailedTalk.isOverflow,

format: findItemById(descriptor.talkFormats, detailedTalk.formatId, "format"),
language: findItemById(descriptor.supportedTalkLanguages, detailedTalk.langId, "language").id,
track: findItemById(descriptor.talkTracks, detailedTalk.trackId, "track"),
room: findItemById(descriptor.rooms, detailedTalk.roomId, "room"),
}))

const event: FullEvent = {
id: eventId,
info: eventInfo,
daySchedules: dailySchedules,
talks: descriptor.talks.map(detailedTalk => ({
start: detailedTalk.start,
end: detailedTalk.end,
summary: detailedTalk.summary,
description: detailedTalk.summary,
tags: detailedTalk.tags,
assets: detailedTalk.assets,
speakers: detailedTalk.speakers,
id: detailedTalk.id,
title: detailedTalk.title,
isOverflow: detailedTalk.isOverflow,

format: findItemById(descriptor.talkFormats, detailedTalk.formatId, "format"),
language: findItemById(descriptor.supportedTalkLanguages, detailedTalk.langId, "language").id,
track: findItemById(descriptor.talkTracks, detailedTalk.trackId, "track"),
room: findItemById(descriptor.rooms, detailedTalk.roomId, "room"),
})),
talks,
conferenceDescriptor: {
...eventInfo,
headingTitle: descriptor.headingTitle,
Expand All @@ -150,7 +152,8 @@ export const SINGLE_FILE_CRAWLER: CrawlerKind<typeof SINGLE_FILE_DESCRIPTOR_PARS
rooms: descriptor.rooms,
infos: descriptor.infos,
formattings: descriptor.formattings,
}
},
lineupSpeakers: detailedTalksToSpeakersLineup(talks),
}
return event
}
Expand Down
3 changes: 2 additions & 1 deletion cloud/functions/src/crawlers/web2day/crawler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {z} from "zod";
import {FullEvent} from "../../models/Event";
import {detailedTalksToSpeakersLineup, FullEvent} from "../../models/Event";
import {
BreakTimeSlot,
DailySchedule, DetailedTalk, ScheduleTimeSlot,
Expand Down Expand Up @@ -306,6 +306,7 @@ export const WEB2DAY_CRAWLER: CrawlerKind<typeof WEB2DAY_PARSER> = {
conferenceDescriptor: confDescriptor,
daySchedules: dailySchedules,
talks: detailedTalks,
lineupSpeakers: detailedTalksToSpeakersLineup(detailedTalks),
};

return fullEvent;
Expand Down
42 changes: 40 additions & 2 deletions cloud/functions/src/models/Event.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,57 @@
import { ListableEvent } from "../../../../shared/event-list.firestore";
import {BreakTimeSlot, DailySchedule, DetailedTalk, Talk} from "../../../../shared/daily-schedule.firestore";
import {
BreakTimeSlot,
DailySchedule,
DetailedTalk,
} from "../../../../shared/daily-schedule.firestore";
import {ConferenceDescriptor} from "../../../../shared/conference-descriptor.firestore";
import {Replace} from "../../../../shared/type-utils";
import {LineupSpeaker} from "../../../../shared/event-lineup.firestore";
import {match, P} from "ts-pattern";

export type BreakTimeslotWithPotentiallyUnknownIcon = Replace<BreakTimeSlot, {
break: Replace<BreakTimeSlot['break'], {
icon: BreakTimeSlot['break']['icon'] | 'unknown'
}>
}>

export interface FullEvent {
export type FullEvent = {
id: string,
conferenceDescriptor: Omit<ConferenceDescriptor, "eventFamily"|"eventName"|"websiteUrl"|"visibility"|"spaceToken">,
info: Omit<ListableEvent, "eventFamily"|"eventName"|"websiteUrl"|"visibility"|"spaceToken">,
daySchedules: DailySchedule[],
talks: DetailedTalk[],
lineupSpeakers: LineupSpeaker[],
}

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;
})

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,
},
})
})
return speakers;
}, [] as LineupSpeaker[])
}
20 changes: 20 additions & 0 deletions shared/event-lineup.firestore.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {Room, Speaker, TalkAsset, TalkFormat, Track} from "./daily-schedule.firestore";
import type {ISODatetime} from "./type-utils";

export type LineupTalk = {
id: string,
title: string,
format: TalkFormat,
language: string,
track: Track,
tags: string[],
allocation: {
room: Room,
start: ISODatetime,
end: ISODatetime,
}|undefined,
}

export type LineupSpeaker = Speaker & {
talks: LineupTalk[],
}

0 comments on commit c88deee

Please sign in to comment.