import { WrappedData, AuthorStats, FileCommits } from './types.js'; export class StatsCalculator { constructor(private data: WrappedData) {} getTeamSummary() { return this.data.teamSummary; } getBusiestMonths() { return this.data.busiestMonths || []; } getBusiestDays() { return this.data.busiestDays || []; } getCommitsByDayOfWeek() { return this.data.commitsByDayOfWeek || {}; } getRepository() { return this.data.repository; } getPeriod() { return this.data.period; } getAuthorStats(author: string): AuthorStats { const commits = this.data.commitsByAuthor[author] || 0; const linesData = this.data.linesChangedByAuthor[author] || { added: 0, removed: 0, net: 0 }; const longestStreak = this.data.longestStreakByAuthor[author] || 0; const activeDays = this.data.uniqueActiveDaysByAuthor?.[author] || 0; const topFiles = this.data.topFilesByAuthor?.[author] || []; const mostActiveHour = this.data.mostActiveHourByAuthor?.[author]?.hour; const mostActiveDay = this.data.mostActiveDayByAuthor?.[author]?.day; const avgCommitMessageLength = this.data.avgCommitMessageLength?.[author] || 0; const nightOwlCommits = this.data.nightOwlCommits?.[author] || 0; const earlyBirdCommits = this.data.earlyBirdCommits?.[author] || 0; const fridayWarriorCommits = this.data.fridayWarriorCommits?.[author] || 0; const weekendWarriorCommits = this.data.weekendWarriorCommits?.[author] || 0; const prs = this.data.pullRequests?.prsByAuthor?.[author]; const mostCommentedPR = this.data.pullRequests?.mostCommentedPRByAuthor?.[author]; // Determine badge let badge = '🎯 Contributeur'; if (commits > 500) badge = '🏆 Légende du Code'; else if (commits > 200) badge = '⭐ Expert'; else if (commits > 100) badge = '💪 Pro'; else if (commits > 50) badge = '🚀 Actif'; return { name: author, commits, linesAdded: linesData.added, linesRemoved: linesData.removed, netLines: linesData.net, activeDays, longestStreak, mostActiveHour, mostActiveDay, topFiles, prs, mostCommentedPR, avgCommitMessageLength, nightOwlCommits, earlyBirdCommits, fridayWarriorCommits, weekendWarriorCommits, badge }; } }