Skip to content

Commit

Permalink
Populate extraPeople from the FOSDEM track managers
Browse files Browse the repository at this point in the history
  • Loading branch information
reivilibre committed Nov 28, 2024
1 parent 2636d92 commit e153bb0
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 12 deletions.
44 changes: 34 additions & 10 deletions src/backends/pretalx/FOSDEMPretalxApiClient.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,54 @@
import { Role } from "../../models/schedule";
import { PretalxApiClient } from "./PretalxApiClient";

export interface FOSDEMPerson {
person_id: number,
event_role: Role,
name: string,
email: string,
matrix_id: string,
}

export interface FOSDEMTalk {
event_id: number,
title: string,
conference_room: string,
start_datetime: string,
duration: number,
track_id: number,
persons: [{
person_id: number,
event_role: Role,
name: string,
email: string,
matrix_id: string,
}]
persons: FOSDEMPerson[]
}

export interface FOSDEMTrack {
/* Numeric ID of the track */
id: number,

/* URL-safe slug of the track */
slug: string,

/* Human-safe name for the track */
name: string,

/* What sort of track this is. `"devroom"` or `"maintrack"`. */
type: string,

/* List of managers of this track */
managers: FOSDEMPerson[],
}

export interface FOSDEMConference {
tracks: FOSDEMTrack[],
talks: FOSDEMTalk[],
}

export class FOSDEMPretalxApiClient extends PretalxApiClient {
async getFOSDEMTalks(): Promise<FOSDEMTalk[]> {
async getFOSDEMConference(): Promise<FOSDEMConference> {
const url = new URL(this.baseUri + `/p/matrix/`);
const req = await fetch(url, this.requestInit);
if (!req.ok) {
const reason = await req.text();
throw Error(`Failed to request events from Pretalx: ${req.status} ${reason}`);
}
return (await req.json()).talks as FOSDEMTalk[];
return (await req.json()) as FOSDEMConference;
}
}
}
23 changes: 21 additions & 2 deletions src/backends/pretalx/PretalxBackend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,26 @@ export class PretalxScheduleBackend implements IScheduleBackend {

private async hydrateFromApi() {
if (this.apiClient instanceof FOSDEMPretalxApiClient) {
for (const apiTalk of await this.apiClient.getFOSDEMTalks()) {
const fosdemConference = await this.apiClient.getFOSDEMConference();

for (const apiTrack of fosdemConference.tracks) {
// This is suspicious, but it seems to be true: auditoriums' IDs
// are actually their names, which may even include spaces!
const localAud = this.auditoriums.get(apiTrack.name);
if (!localAud) {
LogService.warn("PretalxScheduleBackend", `Auditorium missing from public schedule "${apiTrack.name}".`);
continue;
}
localAud.extraPeople = apiTrack.managers.map(manager => ({
id: manager.person_id.toString(),
email: manager.email,
matrix_id: manager.matrix_id,
name: manager.name,
role: manager.event_role,
}));
}

for (const apiTalk of fosdemConference.talks) {
const localTalk = this.talks.get(apiTalk.event_id.toString());
if (!localTalk) {
LogService.warn("PretalxScheduleBackend", `Talk missing from public schedule ${apiTalk.event_id}.`);
Expand Down Expand Up @@ -198,4 +217,4 @@ export class PretalxScheduleBackend implements IScheduleBackend {
get interestRooms(): Map<InterestId, IInterestRoom> {
return this.data.interestRooms;
}
}
}

0 comments on commit e153bb0

Please sign in to comment.