Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to sort auditoria into subspaces by track type #241

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 24 additions & 4 deletions src/Conference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -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];
}
}
Expand Down
70 changes: 70 additions & 0 deletions src/__tests__/backends/json/JsonScheduleBackend.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { test, expect, afterEach, beforeEach, describe } from "@jest/globals";
import { Server, createServer } from "node:http";
import { AddressInfo } from "node:net";
import path from "node:path";
import * as fs from "fs";
import { IConfig, JsonScheduleFormat } from "../../../config";
import { JsonScheduleBackend } from "../../../backends/json/JsonScheduleBackend";

function getFixture(fixtureFile: string) {
return fs.readFileSync(path.join(__dirname, fixtureFile), "utf8");
}

function jsonScheduleServer() {
return new Promise<Server>((resolve) => {
const server = createServer((req, res) => {
if (req.url === "/schedule.json") {
res.writeHead(200);
const json = getFixture("original_democon.json");
res.end(json);
} else if (req.url === "/fosdem/p/matrix") {
if (req.headers.authorization !== "Bearer TOKEN") {
res.writeHead(401);
res.end("Not authorised");
return;
}
res.writeHead(200);
const json = getFixture("fosdem_democon.json");
res.end(json);
} else {
console.log(req.url);
res.writeHead(404);
res.end("Not found");
}
}).listen(undefined, "127.0.0.1", undefined, () => {
resolve(server);
});
});
}

describe("JsonScheduleBackend", () => {
let serv;
beforeEach(async () => {
serv = await jsonScheduleServer();
});
afterEach(async () => {
serv.close();
});

test("can parse a FOSDEM JSON format", async () => {
const globalConfig = { conference: { name: "DemoCon" } } as IConfig;
const backend = await JsonScheduleBackend.new(
"/dev/null",
{
backend: "json",
scheduleFormat: JsonScheduleFormat.FOSDEM,
scheduleDefinition: `http://127.0.0.1:${
(serv.address() as AddressInfo).port
}/fosdem/p/matrix`,
scheduleRequestHeaders: {
"Authorization": "Bearer TOKEN"
}
},
globalConfig
);
expect(backend.conference.title).toBe("DemoCon");
expect(backend.auditoriums).toMatchSnapshot("auditoriums");
expect(backend.talks).toMatchSnapshot("talks");
expect(backend.interestRooms.size).toBe(0);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`JsonScheduleBackend can parse a FOSDEM JSON format: auditoriums 1`] = `
Map {
"5" => {
"id": "5",
"isPhysical": true,
"kind": "auditorium",
"name": "Open CAD/CAM devroom",
"slug": "open_cad_cam",
"talks": Map {
"3" => {
"auditoriumId": "5",
"dateTs": 1706745600000,
"endTime": 1706778000000,
"id": "3",
"livestream_endTime": 1706778000000,
"prerecorded": false,
"qa_startTime": 0,
"speakers": [
{
"email": "ioferrell@localhost",
"id": "4",
"matrix_id": "",
"name": "Iarlaith O'Ferrell",
"role": "speaker",
},
{
"email": "niamh@localhost",
"id": "5",
"matrix_id": "",
"name": "Niamh O'Donnellan",
"role": "speaker",
},
{
"email": "[email protected]",
"id": "1",
"matrix_id": "@conal:example.org",
"name": "Conal Cördinator",
"role": "coordinator",
},
],
"startTime": 1706778000000,
"subtitle": "",
"title": "Panacea3D: The Final Word in Open Source 3D Solid Modelling",
},
},
"trackType": "devroom",
},
"6" => {
"id": "6",
"isPhysical": true,
"kind": "auditorium",
"name": "Self-Hosted Software devroom",
"slug": "selfhosting",
"talks": Map {
"14" => {
"auditoriumId": "6",
"dateTs": 1706745600000,
"endTime": 1706779800000,
"id": "14",
"livestream_endTime": 1706779800000,
"prerecorded": false,
"qa_startTime": 0,
"speakers": [
{
"email": "tysnr@localhost",
"id": "42",
"matrix_id": "",
"name": "Yasunori Takeda",
"role": "speaker",
},
{
"email": "[email protected]",
"id": "246",
"matrix_id": "@chloe:example.org",
"name": "Chloé Coordinator",
"role": "coordinator",
},
],
"startTime": 1706779800000,
"subtitle": "",
"title": "A new architecture for Local-First Computing without boundaries",
},
"19" => {
"auditoriumId": "6",
"dateTs": 1706745600000,
"endTime": 1706783400000,
"id": "19",
"livestream_endTime": 1706783400000,
"prerecorded": false,
"qa_startTime": 0,
"speakers": [
{
"email": "vivaldo@localhost",
"id": "94",
"matrix_id": "@vivaldo:example.org",
"name": "Vivaldo Corradetti",
"role": "speaker",
},
{
"email": "[email protected]",
"id": "246",
"matrix_id": "@chloe:example.org",
"name": "Chloé Coordinator",
"role": "coordinator",
},
],
"startTime": 1706783400000,
"subtitle": "",
"title": "Devising a Blended Federation Topology that reaches Cosmique Perfection",
},
},
"trackType": "devroom",
},
"7" => {
"id": "7",
"isPhysical": true,
"kind": "auditorium",
"name": "Keynotes (TALKS NOT ANNOUNCED YET)",
"slug": "key_notes",
"talks": Map {},
"trackType": "maintrack",
},
}
`;

exports[`JsonScheduleBackend can parse a FOSDEM JSON format: talks 1`] = `
Map {
"3" => {
"auditoriumId": "5",
"dateTs": 1706745600000,
"endTime": 1706778000000,
"id": "3",
"livestream_endTime": 1706778000000,
"prerecorded": false,
"qa_startTime": 0,
"speakers": [
{
"email": "ioferrell@localhost",
"id": "4",
"matrix_id": "",
"name": "Iarlaith O'Ferrell",
"role": "speaker",
},
{
"email": "niamh@localhost",
"id": "5",
"matrix_id": "",
"name": "Niamh O'Donnellan",
"role": "speaker",
},
{
"email": "[email protected]",
"id": "1",
"matrix_id": "@conal:example.org",
"name": "Conal Cördinator",
"role": "coordinator",
},
],
"startTime": 1706778000000,
"subtitle": "",
"title": "Panacea3D: The Final Word in Open Source 3D Solid Modelling",
},
"14" => {
"auditoriumId": "6",
"dateTs": 1706745600000,
"endTime": 1706779800000,
"id": "14",
"livestream_endTime": 1706779800000,
"prerecorded": false,
"qa_startTime": 0,
"speakers": [
{
"email": "tysnr@localhost",
"id": "42",
"matrix_id": "",
"name": "Yasunori Takeda",
"role": "speaker",
},
{
"email": "[email protected]",
"id": "246",
"matrix_id": "@chloe:example.org",
"name": "Chloé Coordinator",
"role": "coordinator",
},
],
"startTime": 1706779800000,
"subtitle": "",
"title": "A new architecture for Local-First Computing without boundaries",
},
"19" => {
"auditoriumId": "6",
"dateTs": 1706745600000,
"endTime": 1706783400000,
"id": "19",
"livestream_endTime": 1706783400000,
"prerecorded": false,
"qa_startTime": 0,
"speakers": [
{
"email": "vivaldo@localhost",
"id": "94",
"matrix_id": "@vivaldo:example.org",
"name": "Vivaldo Corradetti",
"role": "speaker",
},
{
"email": "[email protected]",
"id": "246",
"matrix_id": "@chloe:example.org",
"name": "Chloé Coordinator",
"role": "coordinator",
},
],
"startTime": 1706783400000,
"subtitle": "",
"title": "Devising a Blended Federation Topology that reaches Cosmique Perfection",
},
}
`;
Loading
Loading