Skip to content

Commit af6514a

Browse files
committed
Merge branch 'develop' into 74-speakers-listing-view
2 parents b2f72c0 + 0ec9583 commit af6514a

File tree

6 files changed

+55
-27
lines changed

6 files changed

+55
-27
lines changed

cloud/functions/src/crawlers/codeurs-en-seine/crawler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ export const CODEURS_EN_SEINE_CRAWLER: CrawlerKind<typeof CODEURS_EN_SEINE_PARSE
208208
talkOrBreak
209209
]).with([ P.nullish, {type:"break"} ], ([_, breakSlot]) => {
210210
const breakTimeslot: BreakTimeSlot = {
211-
id: `${breakSlot.start}--${breakSlot.end}`,
211+
id: `${breakSlot.start}--${breakSlot.end}--${breakSlot.breakSlot.room.id}`,
212212
type: 'break',
213213
start: breakSlot.start,
214214
end: breakSlot.end,
@@ -245,7 +245,7 @@ export const CODEURS_EN_SEINE_CRAWLER: CrawlerKind<typeof CODEURS_EN_SEINE_PARSE
245245
return timeslots;
246246
}, [] as ScheduleTimeSlot[]).concat(descriptor.additionalBreaks.map(addBreak => ({
247247
...addBreak.breakTimeslot,
248-
id: `${addBreak.breakTimeslot.start}--${addBreak.breakTimeslot.end}` as ScheduleTimeSlot['id'],
248+
id: `${addBreak.breakTimeslot.start}--${addBreak.breakTimeslot.end}--${HALL_ROOM.id}` as BreakTimeSlot['id'],
249249
type: 'break',
250250
break: {
251251
...addBreak.breakTimeslot.break,

cloud/functions/src/crawlers/crawl.ts

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import {ConferenceOrganizerSpace} from "../../../../shared/conference-organizer-
1010
import {eventLastUpdateRefreshed} from "../functions/firestore/firestore-utils";
1111
import {http} from "./utils";
1212
import {
13+
BreakTimeSlot,
14+
DailySchedule,
1315
DetailedTalk,
1416
Room, TalkAsset,
1517
TalkFormat,
@@ -27,6 +29,7 @@ import {
2729
resolvedEventFirestorePath,
2830
} from "../../../../shared/utilities/event-utils";
2931
import {createAllSpeakers} from "../functions/firestore/services/event-utils";
32+
import { DocumentSnapshot } from "firebase-admin/firestore";
3033

3134
export type CrawlerKind<ZOD_TYPE extends z.ZodType> = {
3235
crawlerImpl: (eventId: string, crawlerDescriptor: z.infer<ZOD_TYPE>, criteria: { dayIds?: string[]|undefined }) => Promise<FullEvent>,
@@ -392,9 +395,35 @@ const saveEvent = async function (event: FullEvent, crawlerDescriptor: z.infer<t
392395

393396
await Promise.all(event.daySchedules.map(async daySchedule => {
394397
try {
395-
await firestoreEvent
396-
.collection("days").doc(daySchedule.day)
397-
.set(daySchedule)
398+
const dayDoc = firestoreEvent.collection("days").doc(daySchedule.day);
399+
400+
const alreadyPersistedScheduleDoc = (await dayDoc.get()) as DocumentSnapshot<DailySchedule>;
401+
const alreadyPersistedSchedule = alreadyPersistedScheduleDoc.data();
402+
403+
// Ensuring existing (legacy) break timeslot ids are kept across new crawls()
404+
// as we changed the rule in feb 2025, including room in break timeslot ids
405+
// Note that this shouldn't be *that* problematic and we might remove this particular case handling at some point
406+
// in time, because no break timeslot id is supposed to be referenced anywhere (only talks timeslot ids
407+
// are supposed to be referenced in feedbacks ... and even those are not supposed to exist either)
408+
if(alreadyPersistedSchedule) {
409+
daySchedule.timeSlots.forEach(timeslotToPersist => {
410+
if(timeslotToPersist.type === 'break') {
411+
const existingPersistedScheduleWithLegacyId = alreadyPersistedSchedule.timeSlots
412+
.filter((persistedTimeslot): persistedTimeslot is BreakTimeSlot => persistedTimeslot.type === 'break')
413+
.find(persistedTimeslot => {
414+
return persistedTimeslot.type === 'break'
415+
&& `${timeslotToPersist.start}--${timeslotToPersist.end}` === `${persistedTimeslot.start}--${persistedTimeslot.end}`
416+
&& timeslotToPersist.id !== persistedTimeslot.id;
417+
})
418+
419+
if(existingPersistedScheduleWithLegacyId) {
420+
timeslotToPersist.id = existingPersistedScheduleWithLegacyId.id;
421+
}
422+
}
423+
})
424+
}
425+
426+
await dayDoc.set(daySchedule)
398427
}catch(e) {
399428
error(`Error while saving dailySchedule ${daySchedule.day}: ${e?.toString()}`)
400429
}

cloud/functions/src/crawlers/devoxx-scala/crawler.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ export const DEVOXX_SCALA_CRAWLER: CrawlerKind<typeof DEVOXX_SCALA_DESCRIPTOR_PA
129129
const start = Temporal.Instant.fromEpochMilliseconds(timeslot.fromTimeMillis).toString() as ISODatetime,
130130
end = Temporal.Instant.fromEpochMilliseconds(timeslot.toTimeMillis).toString() as ISODatetime;
131131

132-
const timeslotId: ScheduleTimeSlot['id'] = `${start}--${end}`
132+
const timeRangeId = `${start}--${end}` as const;
133+
const base = { start, end }
133134

134135
return match(timeslot)
135136
.with({talk: P.not(P.nullish)}, ({talk}) => {
@@ -210,10 +211,11 @@ export const DEVOXX_SCALA_CRAWLER: CrawlerKind<typeof DEVOXX_SCALA_DESCRIPTOR_PA
210211

211212
talks.push(detailedTalk);
212213

213-
return { id: timeslotId, start, end, type: 'talks', talk: detailedTalk };
214+
return { id: timeRangeId, start, end, type: 'talks', talk: detailedTalk };
214215
}).with({break: P.not(P.nullish)}, ({break: breakEntry}) => {
215216
const breakSlot: BreakTimeSlot = {
216-
id: timeslotId, start, end,
217+
...base,
218+
id: `${timeRangeId}--${room.id}`,
217219
type: 'break',
218220
break: {
219221
title: breakEntry.nameEN,
@@ -232,14 +234,14 @@ export const DEVOXX_SCALA_CRAWLER: CrawlerKind<typeof DEVOXX_SCALA_DESCRIPTOR_PA
232234
})
233235

234236
const voxxrinSchedule = rawSlots.reduce((schedule, rawSlot) => {
235-
match([schedule.timeSlots.find(ts => ts.id === rawSlot.id && ts.type === rawSlot.type), rawSlot ])
237+
match([schedule.timeSlots.find(ts => `${ts.start}--${ts.end}` === `${rawSlot.start}--${rawSlot.end}` && ts.type === rawSlot.type), rawSlot ])
236238
.with([ P.nullish, P._ ], () => {
237239
const createdTimeslot: ScheduleTimeSlot = match(rawSlot)
238240
.with({ type:'break'}, (breakSlot: BreakTimeSlot) => {
239241
return breakSlot;
240242
}).with({ type: 'talks'}, (talkSlot) => {
241243
const talkTimeslot: TalksTimeSlot = {
242-
id: talkSlot.id,
244+
id: `${talkSlot.start}--${talkSlot.end}`,
243245
start: talkSlot.start,
244246
end: talkSlot.end,
245247
type: 'talks',

cloud/functions/src/crawlers/full-event.builder.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ export class FullEventBuilder {
232232
const timeslot: TalksTimeSlot = match(this.talkTimeslots.find(timeslot => timeslot.start === timeslotBase.start && timeslot.end === timeslotBase.end))
233233
.with(P.nullish, () => {
234234
const timeslot: TalksTimeSlot = {
235-
id: timeslotBase.id,
235+
id: `${timeslotBase.start}--${timeslotBase.end}`,
236236
start: timeslotBase.start,
237237
end: timeslotBase.end,
238238
type: "talks",
@@ -321,7 +321,7 @@ export class FullEventBuilder {
321321
}
322322

323323
const breakTimeslot: BreakTimeSlot = {
324-
id: timeslotBase.id,
324+
id: `${timeslotBase.start}--${timeslotBase.end}--${roomId}`,
325325
start: timeslotBase.start,
326326
end: timeslotBase.end,
327327
type: 'break',
@@ -418,8 +418,5 @@ export class FullEventBuilder {
418418
function timeslotBaseOf(start: ISODatetime, duration: Parameters<Temporal.Instant['add']>[0]) {
419419
const utcStart = Temporal.Instant.from(start).toString() as ISODatetime;
420420
const utcEnd = Temporal.Instant.from(start).add(duration).toString() as ISODatetime;
421-
const id: TimeSlotBase['id'] = `${utcStart}--${utcEnd}`
422-
423-
const base: TimeSlotBase = { id, start: utcStart, end: utcEnd }
424-
return base;
421+
return { start: utcStart, end: utcEnd };
425422
}

cloud/functions/src/crawlers/la-product-conf/crawler.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,17 +125,17 @@ export const LA_PRODUCT_CONF_CRAWLER: CrawlerKind<typeof LA_PRODUCT_CONF_DESCRIP
125125
const originalStart = ts.timerange.start || rawTimeslots[idx-1].timerange.end as ISODatetime;
126126
const originalEnd = ts.timerange.end || rawTimeslots[idx+1]?.timerange?.start || `${LOCAL_DATE}T${DAY.endTime}` as ISODatetime;
127127

128-
const originalTimeslotId = `${originalStart}--${originalEnd}` as const;
129-
const overrides = descriptor.timeslotOverrides[originalTimeslotId];
128+
const timeRange = `${originalStart}--${originalEnd}` as const;
129+
const overrides = descriptor.timeslotOverrides[timeRange];
130130

131131
const { start, end, timeslotId} = {
132132
start: originalStart,
133133
end: originalEnd,
134-
timeslotId: originalTimeslotId,
134+
timeslotId: timeRange,
135135
...(overrides?.type === 'replace' ? {
136136
start: overrides.replacement.start || originalStart,
137137
end: overrides.replacement.end || originalEnd,
138-
timeslotId: overrides.replacement.id || originalTimeslotId,
138+
timeslotId: overrides.replacement.id || timeRange,
139139
} : {})
140140
}
141141

@@ -145,7 +145,7 @@ export const LA_PRODUCT_CONF_CRAWLER: CrawlerKind<typeof LA_PRODUCT_CONF_DESCRIP
145145
const breakTimeslot: BreakTimeSlot = {
146146
start,
147147
end,
148-
id: timeslotId,
148+
id: `${timeslotId}--${room.id}`,
149149
type: 'break',
150150
break: {
151151
title: ts.breakLabel,
@@ -189,7 +189,7 @@ export const LA_PRODUCT_CONF_CRAWLER: CrawlerKind<typeof LA_PRODUCT_CONF_DESCRIP
189189

190190
const talksTimeslot: TalksTimeSlot = {
191191
start, end,
192-
id: timeslotId,
192+
id: timeRange,
193193

194194
type: 'talks',
195195
talks: [{

cloud/functions/src/crawlers/openplanner/crawler.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ export const OPENPLANNER_CRAWLER: CrawlerKind<typeof OPENPLANNER_DESCRIPTOR_PARS
168168
const start = startInstant.toString() as ISODatetime,
169169
end = endInstant.toString() as ISODatetime;
170170

171-
const timeslotId = `${start}--${end}` as const
171+
const timeRangeId = `${start}--${end}` as const
172172

173173
const room = match(rooms.find(r => r.id === session.trackId)) // track is room in openplanner
174174
.with(P.nullish, () => {
@@ -185,7 +185,7 @@ export const OPENPLANNER_CRAWLER: CrawlerKind<typeof OPENPLANNER_DESCRIPTOR_PARS
185185
const breakSlot: BreakTimeslotWithPotentiallyUnknownIcon = {
186186
type: 'break',
187187
start, end,
188-
id: timeslotId,
188+
id: `${timeRangeId}--${room.id}`,
189189
break: {
190190
title: session.title,
191191
room,
@@ -249,10 +249,10 @@ export const OPENPLANNER_CRAWLER: CrawlerKind<typeof OPENPLANNER_DESCRIPTOR_PARS
249249

250250
talks.push(detailedTalk);
251251

252-
const talksTimeslot = match(talkTimeslots.find(ts => ts.id === timeslotId))
252+
const talksTimeslot = match(talkTimeslots.find(ts => ts.id === timeRangeId))
253253
.with(P.nullish, () => {
254254
const talksTimeslot: TalksTimeSlot = {
255-
id: timeslotId,
255+
id: timeRangeId,
256256
start, end,
257257
type: 'talks',
258258
talks: []
@@ -274,7 +274,7 @@ export const OPENPLANNER_CRAWLER: CrawlerKind<typeof OPENPLANNER_DESCRIPTOR_PARS
274274
timezone, breakTimeslotsWithPotentiallyUnknownIcons, talkTimeslots)
275275
.concat((descriptor.additionalBreakTimeslots || []).map(partialTimeslot => ({
276276
...partialTimeslot,
277-
id: `${partialTimeslot.start as ISODatetime}--${partialTimeslot.end as ISODatetime}`,
277+
id: `${partialTimeslot.start as ISODatetime}--${partialTimeslot.end as ISODatetime}--${partialTimeslot.break.room.id}`,
278278
type: 'break'
279279
})))
280280

0 commit comments

Comments
 (0)