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/local-coding/sync/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export async function POST(req: NextRequest) {
);
}

const incomingDates = [...new Set(newSessions.map((session) => session.date))];
const incomingDates = [...new Set((newSessions ?? []).map((session) => session.date))];
const { data: existingSessionsForDates } = await supabaseAdmin
.from("local_coding_sessions")
.select("date")
Expand Down Expand Up @@ -278,7 +278,7 @@ export async function GET(req: NextRequest) {
}

const { searchParams } = new URL(req.url);
const rawDays = parseInt(searchParams.get("days") || "30", 10);
const rawDays = parseInt(searchParams.get("days", 10) || "30", 10);
const days = validateDays(isNaN(rawDays) ? DEFAULT_DAYS : rawDays);
const fromDate = new Date();
fromDate.setDate(fromDate.getDate() - days);
Expand Down
4 changes: 2 additions & 2 deletions src/app/api/metrics/languages/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
const data = await withMetricsCache({ bypass, key, ttlSeconds: METRICS_CACHE_TTL_SECONDS.languages }, async () => {
const headers = { Authorization: `Bearer ${token}`, Accept: "application/vnd.github+json" };
const since = new Date();
const rawDays = parseInt(req.nextUrl.searchParams.get("days") ?? "90", 10); const days = Number.isFinite(rawDays) && rawDays > 0 ? Math.min(rawDays, 365) : 90;
const rawDays = parseInt(req.nextUrl.searchParams.get("days", 10) ?? "90", 10); const days = Number.isFinite(rawDays) && rawDays > 0 ? Math.min(rawDays, 365) : 90;

const searchRes = await fetch(
`${GITHUB_API}/search/commits?q=author:${githubLogin}+author-date:>=${since.toISOString().slice(0, 10)}&per_page=100&sort=author-date&order=desc`,
Expand All @@ -65,7 +65,7 @@
if (!searchRes.ok) throw new Error("API Error");

const raw = await searchRes.json();
const repoNames = Array.from(new Set<string>(raw.items.map((i: any) => i.repository.full_name)));
const repoNames = Array.from(new Set<string>(raw.(items ?? []).map((i: any) => i.repository.full_name)));

Check failure on line 68 in src/app/api/metrics/languages/route.ts

View workflow job for this annotation

GitHub Actions / Type check

Identifier expected.
const topRepoNames = repoNames.slice(0, 20);
const langTotals: Record<string, number> = {};
const failedRepos: Array<{ name: string; statusCode?: number; error: string }> = [];
Expand Down
2 changes: 1 addition & 1 deletion src/app/api/metrics/repo-health/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export async function GET(req: NextRequest) {
return Response.json({ error: "Unauthorized" }, { status: 401 });
}

const requestedDays = parseInt(req.nextUrl.searchParams.get("days") ?? "30", 10);
const requestedDays = parseInt(req.nextUrl.searchParams.get("days", 10) ?? "30", 10);
// Only allow 7, 30, or 90 day windows — other values default to 30.
const days = requestedDays === 7 || requestedDays === 30 || requestedDays === 90 ? requestedDays : 30;

Expand Down
6 changes: 3 additions & 3 deletions src/components/ContributionHeatmap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ export default function ContributionHeatmap({
commits.forEach((c) => {
if (c.repo) reposSet.add(c.repo);
});
return Array.from(reposSet).sort();
return Array.from(reposSet).sort((a, b) => a - b);
}, [commits]);

// Extract unique languages
Expand All @@ -329,7 +329,7 @@ export default function ContributionHeatmap({
if (l.name) langsSet.add(l.name);
});
});
return Array.from(langsSet).sort();
return Array.from(langsSet).sort((a, b) => a - b);
}, [reposData]);

// Map each repo to its languages for quick lookup
Expand Down Expand Up @@ -379,7 +379,7 @@ export default function ContributionHeatmap({
);
const weekCount = Math.ceil(cells.length / 7);
const maxCommits = Math.max(
...cells.map((cell) => cell.count),
...(cells ?? []).map((cell) => cell.count),
1
);
// 100% MATHEMATICALLY PRECISE MONTH TRACKING SYSTEM
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useRealtimeSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export function useRealtimeSync(

// Stabilise `events` so an inline array definition (e.g. `["INSERT", "DELETE"]`)
// doesn't cause the effect to re-run on every render.
const eventsKey = [...events].sort().join(",");
const eventsKey = [...events].sort((a, b) => a - b).join(",");

useEffect(() => {
const supabase = getSupabaseClient();
Expand Down
Loading