@@ -10,6 +10,8 @@ import {ConferenceOrganizerSpace} from "../../../../shared/conference-organizer-
1010import { eventLastUpdateRefreshed } from "../functions/firestore/firestore-utils" ;
1111import { http } from "./utils" ;
1212import {
13+ BreakTimeSlot ,
14+ DailySchedule ,
1315 DetailedTalk ,
1416 Room , TalkAsset ,
1517 TalkFormat ,
@@ -27,6 +29,7 @@ import {
2729 resolvedEventFirestorePath ,
2830} from "../../../../shared/utilities/event-utils" ;
2931import { createAllSpeakers } from "../functions/firestore/services/event-utils" ;
32+ import { DocumentSnapshot } from "firebase-admin/firestore" ;
3033
3134export 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 }
0 commit comments