Skip to content

Commit 357bf42

Browse files
committed
merging overflow talks in /publicEventStats topTalks entries
1 parent cec26c6 commit 357bf42

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

cloud/functions/src/functions/firestore/services/talk-utils.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,34 @@ class ConfOrganizerAllRatingsModel {
3737
}
3838

3939
export async function getEveryRatingsForEvent(eventId: string, organizerSpaceToken: string) {
40+
// FIXME: move this to conference descriptor at some point
41+
const devoxxOverflowTalkIds: Record<string, string[]> = eventId === 'dvbe23' ? {
42+
"67956": ["72002", "72003", "72004"],
43+
"67953": ["72007", "72006", "72005"],
44+
"70101": ["72009", "72008", "72010"],
45+
}: {}
46+
47+
const talkIdByOverflowTalkId = Object.entries(devoxxOverflowTalkIds).reduce((talkIdByOverflowTalkId, [talkId, overflowTalkIds]) => {
48+
overflowTalkIds.forEach(overflowTalkId => talkIdByOverflowTalkId[overflowTalkId] = talkId);
49+
return talkIdByOverflowTalkId;
50+
}, {} as Record<string, string>)
51+
4052
const dailyRatingsColl = await db.collection(`/events/${eventId}/organizer-space/${organizerSpaceToken}/daily-ratings`).listDocuments()
4153

4254
const allDailyRatings: PerTalkPublicUserIdFeedbackRating[][] = await Promise.all(dailyRatingsColl.map(async dailyRatingsDoc => {
4355
const dailyPerTalkIdRatings = (await dailyRatingsDoc.get()).data() as DailyTalkFeedbackRatings;
56+
57+
Object.entries(talkIdByOverflowTalkId).forEach(([overflowTalkId, aliasedTalkId]) => {
58+
if(dailyPerTalkIdRatings[overflowTalkId]) {
59+
// Merging overflow talk id ratings into aliased talk id ratings
60+
dailyPerTalkIdRatings[aliasedTalkId] = {
61+
...(dailyPerTalkIdRatings[aliasedTalkId] || {}),
62+
...dailyPerTalkIdRatings[overflowTalkId]
63+
}
64+
delete dailyPerTalkIdRatings[overflowTalkId];
65+
}
66+
})
67+
4468
const talkIds = Object.keys(dailyPerTalkIdRatings)
4569
return talkIds.map(talkId => {
4670
return {

0 commit comments

Comments
 (0)