Skip to content

Commit f7a2865

Browse files
authored
Find extra people from the PentaDb during the hydration step (#179)
1 parent cd071c1 commit f7a2865

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

src/__tests__/backends/penta/CachingBackend.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ test("the cache should restore the same talks that were saved", async () => {
6666
role: Role.Speaker
6767
}
6868
]),
69+
findAllPeopleForTalk: jest.fn(PentaDb.prototype.findAllPeopleForTalk).mockResolvedValue([]),
6970
} as any as PentaDb;
7071

7172
async function newPentaBackend(): Promise<PentaBackend> {

src/__tests__/backends/penta/PentaBackend.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ test("talks should be rehydrated from the database", async () => {
6262
role: Role.Speaker
6363
}
6464
]),
65+
findAllPeopleForTalk: jest.fn(PentaDb.prototype.findAllPeopleForTalk).mockResolvedValue([]),
6566
} as any as PentaDb;
6667

6768
const b = new PentaBackend(backendConfig, parser, fakeDb);

src/backends/penta/PentaBackend.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,17 @@ export class PentaBackend implements IScheduleBackend {
7171
const dbTalk = await this.db.getTalk(talk.id);
7272
if (dbTalk === null) return;
7373
this.rehydrateTalkFrom(talk, dbTalk);
74+
75+
// Not all people are listed in the Penta XML!
76+
// Notably, devroom managers ('coordinators') are only available in the database.
77+
// Make sure we get those whilst we hydrate our talk...
78+
for (const person of await this.db.findAllPeopleForTalk(talk.id)) {
79+
// Ensure we don't wind up duplicating people; this step is purely to get people who were missed out of the XML.
80+
if (!talk.speakers.find(s => s.id == person.id)) {
81+
// The person is already hydrated — they're straight from the DB — so no hydration step needed here.
82+
talk.speakers.push(person);
83+
}
84+
}
7485
}
7586

7687
private rehydrateTalkFrom(talk: ITalk, dbTalk: IDbTalk): void {

src/models/schedule.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ export interface ITalk {
5656
title: string;
5757
subtitle: string;
5858
track: string;
59+
/**
60+
* MISNOMER: This variable contains ALL people for the talk, NOT JUST speakers.
61+
* TODO rename (at a time when it's a less risky change to do...)
62+
*/
5963
speakers: IPerson[];
6064
prerecorded: boolean;
6165
/**

0 commit comments

Comments
 (0)