@@ -143,12 +143,24 @@ export async function getRepoTree(owner: string, repo: string) {
143143 }
144144}
145145
146- interface Commit {
147- additions : number ;
148- deletions : number ;
146+ interface GitHubCommit {
147+ sha : string ;
148+ commit : {
149+ message : string ;
150+ author : {
151+ name : string ;
152+ email : string ;
153+ date : string ;
154+ } ;
155+ } ;
156+ stats ?: {
157+ additions : number ;
158+ deletions : number ;
159+ total : number ;
160+ } ;
149161}
150162
151- function analyzeCommits ( commits : Commit [ ] ) {
163+ function analyzeCommits ( commits : any [ ] ) {
152164 if ( commits . length === 0 ) {
153165 return {
154166 workPatternAnalysis : "Not enough commit data to analyze." ,
@@ -164,20 +176,20 @@ function analyzeCommits(commits: Commit[]) {
164176 totalLinesChanged : 0 ,
165177 } ;
166178
167- const firstCommitDate = new Date ( commits [ commits . length - 1 ] . commit . author . date ) ;
168- const lastCommitDate = new Date ( commits [ 0 ] . commit . author . date ) ;
179+ const firstCommitDate = new Date ( commits [ commits . length - 1 ] . commit_date ) ;
180+ const lastCommitDate = new Date ( commits [ 0 ] . commit_date ) ;
169181 const days = Math . max ( differenceInDays ( lastCommitDate , firstCommitDate ) , 1 ) ;
170182 const commitsPerDay = ( commitMetrics . totalCommits / days ) . toFixed ( 1 ) ;
171183
172184 for ( const commit of commits ) {
173- const commitDate = new Date ( commit . commit . author . date ) ;
185+ const commitDate = new Date ( commit . commit_date ) ;
174186 const hour = commitDate . getHours ( ) ;
175187 const day = getDay ( commitDate ) ;
176188
177189 commitMetrics . peakHours [ hour ] = ( commitMetrics . peakHours [ hour ] || 0 ) + 1 ;
178190 commitMetrics . workdays [ day ] = ( commitMetrics . workdays [ day ] || 0 ) + 1 ;
179- if ( commit . stats ) {
180- commitMetrics . totalLinesChanged += commit . stats . total ;
191+ if ( commit . raw_data ?. stats ) {
192+ commitMetrics . totalLinesChanged += commit . raw_data . stats . total ;
181193 }
182194 }
183195
0 commit comments