From db800a6efc3f66d2e6dec7ad1b5c5081cd730f48 Mon Sep 17 00:00:00 2001 From: Olivier 'reivilibre Date: Fri, 27 Dec 2024 11:52:22 +0000 Subject: [PATCH] Add ability to sort auditoria into subspaces by track type --- config/default.yaml | 2 ++ src/Conference.ts | 28 ++++++++++++++++--- src/backends/json/FosdemJsonScheduleLoader.ts | 1 + src/backends/json/JsonScheduleLoader.ts | 1 + src/backends/penta/PentabarfParser.ts | 3 +- src/config.ts | 3 +- src/models/schedule.ts | 7 +++++ 7 files changed, 39 insertions(+), 6 deletions(-) diff --git a/config/default.yaml b/config/default.yaml index bb20590..ea97166 100644 --- a/config/default.yaml +++ b/config/default.yaml @@ -226,6 +226,8 @@ conference: # alias: stands # # The prefixes of rooms which belong in the subspace # prefixes: ["S."] + # # The types of tracks which belong in the subspace + # trackTypes: ["stands"] # Options related to the IRC bridge. Set to null if you don't use an IRC bridge. ircBridge: null diff --git a/src/Conference.ts b/src/Conference.ts index 86837da..729d490 100644 --- a/src/Conference.ts +++ b/src/Conference.ts @@ -672,6 +672,19 @@ export class Conference { /** * Determines the space in which an auditorium space or interest room should reside. + * + * For both auditoria and interest rooms, this is based off a set of configured prefixes for the + * auditorium or interest room ID. + * + * For auditoria, there is the additional option to match on the track type (with a set of configured + * mappings). + * + * ## Historical notes + * + * Matching on track types was added for FOSDEM 2025. Previously, only prefixes were available + * as a matching mechanism but the track type support was needed once auditoria were changed to + * represent tracks instead of being 1:1 mapped to physical in-person rooms. + * * @param auditoriumOrInterestRoom The description of the auditorium or interest room. * @returns The space in which the auditorium or interest room should reside. */ @@ -686,12 +699,19 @@ export class Conference { const id = auditoriumOrInterestRoom.id; for (const [subspaceId, subspaceConfig] of Object.entries(this.config.conference.subspaces)) { - for (const prefix of subspaceConfig.prefixes) { - if (id.startsWith(prefix)) { - if (!(subspaceId in this.subspaces)) { - throw new Error(`The ${subspaceId} subspace has not been created yet!`); + if (subspaceConfig.prefixes !== undefined) { + for (const prefix of subspaceConfig.prefixes) { + if (id.startsWith(prefix)) { + if (!(subspaceId in this.subspaces)) { + throw new Error(`The ${subspaceId} subspace has not been created yet!`); + } + return this.subspaces[subspaceId]; } + } + } + if (subspaceConfig.trackTypes !== undefined && 'trackType' in auditoriumOrInterestRoom) { + if (subspaceConfig.trackTypes.includes(auditoriumOrInterestRoom.trackType)) { return this.subspaces[subspaceId]; } } diff --git a/src/backends/json/FosdemJsonScheduleLoader.ts b/src/backends/json/FosdemJsonScheduleLoader.ts index b410e42..a8d2145 100644 --- a/src/backends/json/FosdemJsonScheduleLoader.ts +++ b/src/backends/json/FosdemJsonScheduleLoader.ts @@ -117,6 +117,7 @@ export class FosdemJsonScheduleLoader { talks: new Map(), // Hardcoded: FOSDEM is always physical now. isPhysical: true, + trackType: track.type, }; } } diff --git a/src/backends/json/JsonScheduleLoader.ts b/src/backends/json/JsonScheduleLoader.ts index 1cdefb5..da957b5 100644 --- a/src/backends/json/JsonScheduleLoader.ts +++ b/src/backends/json/JsonScheduleLoader.ts @@ -104,6 +104,7 @@ export class JsonScheduleLoader { talks, // TODO Support physical auditoriums in the JSON schedule backend isPhysical: false, + trackType: '', }; } } diff --git a/src/backends/penta/PentabarfParser.ts b/src/backends/penta/PentabarfParser.ts index 028aba4..e0dcca7 100644 --- a/src/backends/penta/PentabarfParser.ts +++ b/src/backends/penta/PentabarfParser.ts @@ -211,7 +211,8 @@ export class PentabarfParser { name: metadata.name, kind: metadata.kind, talks: new Map(), - isPhysical: isPhysical + isPhysical: isPhysical, + trackType: '', }; const existingAuditorium = this.auditoriums.find(r => r.id === auditorium.id); if (existingAuditorium) { diff --git a/src/config.ts b/src/config.ts index b5a2ff0..c161b02 100644 --- a/src/config.ts +++ b/src/config.ts @@ -81,7 +81,8 @@ export interface IConfig { [name: string]: { displayName: string; alias: string; - prefixes: string[]; + prefixes?: string[]; + trackTypes?: string[]; }; }; }; diff --git a/src/models/schedule.ts b/src/models/schedule.ts index e5b2f4a..1bd316d 100644 --- a/src/models/schedule.ts +++ b/src/models/schedule.ts @@ -79,6 +79,13 @@ export interface IAuditorium { * If true, this auditorium is just a virtual representation of a real-world physical auditorium. */ isPhysical: boolean; + + /** + * A 'type' of track that this auditorium is in. + * May be an empty string if there is no concept of types. + * This string will not be human-readable. + */ + trackType: string; } export interface IConference {