Last active
September 16, 2018 08:29
-
-
Save icoloma/7d9f45ccbda162ebf418354c2d7a09ab to your computer and use it in GitHub Desktop.
Snippets around the agenda for Commit Conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// transform agenda into a listo of talk descriptions | |
var slots = []; | |
agenda.days.forEach( | |
d => d.tracks.forEach( | |
t => t.slots.forEach( | |
s => { | |
if (s.contents && s.contents.description) { | |
slots.push(s.contents); | |
} | |
} | |
) | |
) | |
) | |
// normalize by penalizing talks with few votes (add a rating of 1 to all talks) | |
function normalize(feedback) { | |
if (!feedback) return 0; | |
return (feedback.ratingAverage * feedback.entriesCount + 1) / (feedback.entriesCount + 1) | |
} | |
// sort talks by a criteria | |
slots.sort((s1, s2) => { | |
var f1 = normalize(s1.feedback); | |
var f2 = normalize(s2.feedback); | |
return f1 - f2 | |
}) | |
// print stuff | |
var output = 'Average,Entries,Title,Twitter Handle\n'; | |
slots.forEach((s) => { | |
var f = s.feedback? s.feedback : { entriesCount: 0, ratingAverage: 0 }; | |
var handles = s.authors.map(({ twitterAccount }) => twitterAccount); | |
output += `${normalize(s.feedback)}, ${f.entriesCount}, "${s.title.replace(/"/g, '\\"')}", ${handles.join(',')}\n` | |
}) | |
console.log(output); | |
/* | |
Not yet supported | |
await navigator.clipboard.writeText(output) | |
console.log("CSV copied to clipboard") | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log(talks.map(({ authors }) => authors.filter(({ twitterAccount }) => !!twitterAccount).map(({ twitterAccount }) => `${twitterAccount}\n` ).join('')).join('')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment