Skip to content

Commit

Permalink
extract displayname
Browse files Browse the repository at this point in the history
  • Loading branch information
ksw2000 committed Nov 19, 2024
1 parent 5161e56 commit ab9461a
Show file tree
Hide file tree
Showing 3 changed files with 835 additions and 62 deletions.
27 changes: 26 additions & 1 deletion misc/convert_speakers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ interface Session {
name: string;
}

interface QuestionAnswers {
id: number;
question: string; // "Display Name",
// questionType: "Short_Text",
answer: string;
// "sort": 20,
// "answerExtra": null
}

interface Speaker {
id: string;
firstName: string;
Expand All @@ -30,6 +39,7 @@ interface Speaker {
isTopSpeaker: boolean;
links: Link[];
sessions: Session[];
questionAnswers: QuestionAnswers[];
}

import * as fs from 'fs';
Expand All @@ -51,6 +61,19 @@ interface ExportedSpeaker {
socials: ExportedLink[];
}

// sessionze 平台名稱欄位不好用因此我們可以從
// Question Answers 抓 display name
function extractDisplayNameFromQuestionAnswers(
qaList: QuestionAnswers[],
): string | null {
for (let i = 0; i < qaList.length; i++) {
if (qaList[i].question == 'Display Name') {
return qaList[i].answer;
}
}
return null;
}

function truncate(value: string): string {
if (value.length > 150) {
return value.substring(0, 150) + '...';
Expand All @@ -73,7 +96,9 @@ for (let i = 0; i < speakers.length; i++) {
}
output.set(speaker.id, {
bio: speaker.bio,
name: speaker.fullName,
name:
extractDisplayNameFromQuestionAnswers(speaker.questionAnswers) ??
speaker.fullName,
order: i,
photo: speaker.profilePicture,
shortBio: truncate(speaker.bio ?? ''),
Expand Down
Loading

0 comments on commit ab9461a

Please sign in to comment.