import { AuthorStats, Slide } from './types.js';
export class SlideGenerator {
generateAuthorSlides(stats: AuthorStats): Slide[] {
const slides: Slide[] = [];
// Welcome slide
slides.push({
title: `L'année de ${stats.name} en code`,
emoji: '👋',
content: `
${stats.name}
${stats.badge}
Votre GitHub Wrapped 2024-2025
`
});
// Commits slide
slides.push({
title: 'Total des commits',
emoji: '📊',
content: `
${stats.commits.toLocaleString()}
commits cette année
`
});
// Lines of code slide
slides.push({
title: 'Lignes de code',
emoji: '💻',
content: `
${stats.linesAdded.toLocaleString()}
lignes ajoutées
${stats.linesRemoved.toLocaleString()}
lignes supprimées
${Math.abs(stats.netLines).toLocaleString()}
net ${stats.netLines >= 0 ? 'ajoutées' : 'supprimées'}
`
});
// Activity patterns
if (stats.mostActiveHour || stats.mostActiveDay) {
slides.push({
title: 'Votre rythme de code',
emoji: '⏰',
content: `
${stats.mostActiveHour ? `
Heure de pointe
${stats.mostActiveHour}
` : ''}
${stats.mostActiveDay ? `
Jour préféré
${stats.mostActiveDay}
` : ''}
Jours actifs
${stats.activeDays}
Plus longue série
${stats.longestStreak} jours
`
});
}
// PRs Stats slide (if available)
if (stats.prs) {
const mergeRate = stats.prs.opened > 0
? Math.round((stats.prs.merged / stats.prs.opened) * 100)
: 0;
slides.push({
title: 'Pull Requests',
emoji: '🔀',
content: `
${stats.prs.opened}
PR ouvertes
${stats.prs.merged}
PR fusionnées
${mergeRate}%
taux de fusion
${stats.mostCommentedPR && stats.mostCommentedPR.comments > 0 ? `
PR la plus discutée : #${stats.mostCommentedPR.prNumber} (${stats.mostCommentedPR.comments} commentaires)
` : ''}
`
});
}
// Work habits slide
const workHabits: string[] = [];
if (stats.fridayWarriorCommits > 10) workHabits.push(`🎉 ${stats.fridayWarriorCommits} commits le vendredi`);
if (stats.weekendWarriorCommits > 0) workHabits.push(`🏋️ ${stats.weekendWarriorCommits} commits le week-end`);
if (stats.nightOwlCommits > 0) workHabits.push(`🦉 ${stats.nightOwlCommits} commits tard le soir`);
if (stats.earlyBirdCommits > 0) workHabits.push(`🌅 ${stats.earlyBirdCommits} commits tôt le matin`);
if (workHabits.length > 0) {
slides.push({
title: 'Habitudes de travail',
emoji: '⏰',
content: `
${workHabits.map(h => `
${h}
`).join('')}
${stats.avgCommitMessageLength > 0 ? `
Message de commit moyen :
${Math.round(stats.avgCommitMessageLength)} caractères
` : ''}
`
});
}
// Special achievements
const achievements: string[] = [];
if (stats.longestStreak > 4) achievements.push(`🔥 Série de ${stats.longestStreak} jours de code`);
if (stats.prs && stats.prs.merged > 80) achievements.push(`✅ ${stats.prs.merged} PR fusionnées`);
if (stats.activeDays > 100) achievements.push(`📅 ${stats.activeDays} jours actifs`);
if (stats.linesAdded > 30000) achievements.push(`📝 ${(stats.linesAdded / 1000).toFixed(1)}K lignes ajoutées`);
if (stats.commits > 200) achievements.push(`💪 ${stats.commits} commits`);
if (achievements.length > 0) {
slides.push({
title: 'Réalisations',
emoji: '🏆',
content: `
${achievements.map(a => `
${a}
`).join('')}
`
});
}
// Top files
if (stats.topFiles.length > 0) {
slides.push({
title: 'Fichiers les plus modifiés',
emoji: '📁',
content: `
${stats.topFiles.slice(0, 5).map(f => `
${f.file}
${f.commits} commits
`).join('')}
`
});
}
return slides;
}
generateTeamSlide(totalCommits: number, totalLines: number): Slide {
return {
title: 'Statistiques de l\'équipe',
emoji: '🎉',
content: `
${totalCommits.toLocaleString()}
commits totaux de l'équipe
${totalLines.toLocaleString()}
lignes totales modifiées
`
};
}
private getMessageLengthComment(length: number): string {
if (length < 30) return '(court et doux)';
if (length < 50) return '(concis)';
if (length < 70) return '(descriptif)';
return '(conteur)';
}
}