Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/app/api/personality/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ interface PRsApiResponse {
interface StreakApiResponse {
current?: number;
longest?: number;
totalActiveDays?: number;
}

interface RepoSummary {
Expand Down Expand Up @@ -211,6 +210,7 @@ export async function GET(request: Request) {
.map(([date, count]) => ({ date, count }))
.sort((a, b) => a.date.localeCompare(b.date));
const totalCommits = commitsArray.reduce((s, d) => s + d.count, 0);
const activeDays = commitsArray.filter(({ count }) => count > 0).length;

const metrics: PersonalityInputMetrics = {
timeBlocks: {
Expand All @@ -220,7 +220,7 @@ export async function GET(request: Request) {
night: contributionsRaw.timeBlocks?.night ?? 0,
},
totalCommits,
activeDays: streakRaw.totalActiveDays ?? 0,
activeDays,
longestStreak: streakRaw.longest ?? 0,
currentStreak: streakRaw.current ?? 0,
prsMerged: prsRaw.merged ?? 0,
Expand Down
15 changes: 15 additions & 0 deletions test/personality-route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,19 @@ describe("GET /api/personality — metric loading", () => {
expect(res.headers.get("Retry-After")).toBe("90");
expect(mocks.upsert).not.toHaveBeenCalled();
});
it("scores consistency using active days from the same commit window", async () => {
mocks.metrics.mockResolvedValue([
{ data: { "2026-01-01": 3, "2026-01-02": 1, "2026-01-03": 0 } },
{ avgReviewHours: 0 },
{ current: 1, longest: 5, totalActiveDays: 45 },
{ repos: [] },
]);

const { GET } = await import("@/app/api/personality/route");
const response = await GET(request());
const { data } = await response.json();

expect(response.status).toBe(200);
expect(data.perfectionismScore).toBe(20);
});
});