Skip to content

Commit 06c4d46

Browse files
committed
add speakers and tags to export
1 parent 871c86b commit 06c4d46

2 files changed

Lines changed: 32 additions & 4 deletions

File tree

src/conf.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,30 @@
11
import fs from "fs";
2-
import { getEvents } from "./fb.js";
2+
import { getEvents, getSpeakers, getTags } from "./fb.js";
33

44
export default async function conference(fbDb, htConf, outputDir) {
55
const childDir = `${outputDir}/conferences/${htConf.code}`;
66

77
fs.mkdirSync(childDir, { recursive: true });
88

9-
const [htEvents] = await Promise.all([getEvents(fbDb, htConf.code)]);
9+
const [htEvents, htSpeakers, htTags] = await Promise.all([
10+
getEvents(fbDb, htConf.code),
11+
getSpeakers(fbDb, htConf.code),
12+
getTags(fbDb, htConf.code),
13+
]);
1014

1115
await Promise.all([
1216
fs.promises.writeFile(`${childDir}/events.json`, JSON.stringify(htEvents)),
17+
fs.promises.writeFile(
18+
`${childDir}/speakers.json`,
19+
JSON.stringify(htSpeakers)
20+
),
21+
fs.promises.writeFile(`${childDir}/tags.json`, JSON.stringify(htTags)),
1322
]);
1423

15-
const eventColors = new Set(htEvents.map((e) => e.type.color));
24+
const eventColors = htEvents.map((e) => e.type.color);
25+
const tagColors = htTags.flatMap((t) =>
26+
t.tags.map((e) => e.color_background)
27+
);
1628

17-
return eventColors;
29+
return new Set(eventColors, tagColors);
1830
}

src/fb.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,19 @@ export async function getEvents(db, conference) {
2424

2525
return firebaseData;
2626
}
27+
28+
export async function getTags(db, conference) {
29+
const docRef = collection(db, "conferences", conference, "tagtypes");
30+
const docSnap = await getDocs(docRef);
31+
const firebaseData = docSnap.docs.flatMap((tagsDoc) => tagsDoc.data()) ?? [];
32+
33+
return firebaseData;
34+
}
35+
36+
export async function getSpeakers(db, conference) {
37+
const docRef = collection(db, "conferences", conference, "speakers");
38+
const docSnap = await getDocs(docRef);
39+
const firebaseData = docSnap.docs.map((speakerDoc) => speakerDoc.data());
40+
41+
return firebaseData;
42+
}

0 commit comments

Comments
 (0)