File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -174,16 +174,16 @@ export function getTopRepositories(repos, limit = 10) {
174174
175175 return [ ...repos ]
176176 . map ( repo => {
177- const daysSinceLastPush =
178- ( Date . now ( ) - new Date ( repo . pushed_at ) . getTime ( ) ) / MS_PER_DAY ;
177+ const pushedAtMs = Date . parse ( repo . pushed_at ) ;
178+ const daysSinceLastPush = Number . isFinite ( pushedAtMs ) ? ( Date . now ( ) - pushedAtMs ) / MS_PER_DAY : Infinity ;
179179
180180 const activityBonus = 0.5 * Math . max ( 0 , 365 - daysSinceLastPush ) ;
181181
182- const score =
183- repo . stargazers_count +
184- repo . forks_count * 2 +
185- repo . watchers_count * 1.5 +
186- activityBonus ;
182+ const score =
183+ ( repo . stargazers_count ?? 0 ) +
184+ ( repo . forks_count ?? 0 ) * 2 +
185+ ( repo . watchers_count ?? 0 ) * 1.5 +
186+ activityBonus ;
187187
188188 return {
189189 ...repo ,
You can’t perform that action at this time.
0 commit comments