Skip to content

Commit d3cc96e

Browse files
committed
fix(technical-debt): sort stale files by age (oldest first)
- Add sorting to stale files by daysSinceLastChange in descending order - Apply sorting to both primary and fallback approaches - Ensures Top 5 Stale Files shows the oldest files first
1 parent 9fb52ee commit d3cc96e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/handlers.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ export function handleGetTechnicalDebt(args: any) {
355355
const days = Math.floor((now - parseInt(timestamp)) / 86400);
356356
return { file, daysSinceLastChange: days };
357357
})
358+
.sort((a, b) => b.daysSinceLastChange - a.daysSinceLastChange)
358359
.slice(0, 10);
359360
} catch {
360361
// Fallback to simpler approach
@@ -371,7 +372,7 @@ export function handleGetTechnicalDebt(args: any) {
371372
}
372373
} catch {}
373374
}
374-
staleFiles = staleFiles.slice(0, 10);
375+
staleFiles = staleFiles.sort((a, b) => b.daysSinceLastChange - a.daysSinceLastChange).slice(0, 10);
375376
}
376377

377378
let complexityHotspots: any[] = [];

0 commit comments

Comments
 (0)