diff --git a/src/app/api/metrics/activity/route.ts b/src/app/api/metrics/activity/route.ts index 648696291..e4f708916 100644 --- a/src/app/api/metrics/activity/route.ts +++ b/src/app/api/metrics/activity/route.ts @@ -74,7 +74,7 @@ async function fetchDiscussionItemsViaGraphQL( token ); const nodes = data?.viewer?.repositoryDiscussionComments?.nodes ?? []; - return nodes.map(formatGraphQLDiscussionComment); + return (nodes ?? []).map(formatGraphQLDiscussionComment); } catch { // Discussions may be disabled, rate-limited, or the token may lack the // required scope — never allow this to block the main activity feed. @@ -167,9 +167,9 @@ export async function GET(req: NextRequest) { let limit = limitParam ? parseInt(limitParam, 10) : 10; let offset = offsetParam ? parseInt(offsetParam, 10) : 0; - if (isNaN(limit) || limit < 1) limit = 10; + if (Number.isNaN(limit) || limit < 1) limit = 10; if (limit > 100) limit = 100; - if (isNaN(offset) || offset < 0) offset = 0; + if (Number.isNaN(offset) || offset < 0) offset = 0; const bypass = isMetricsCacheBypassed(req); const cacheKey = metricsCacheKey( diff --git a/src/app/api/metrics/contributions/hourly/route.ts b/src/app/api/metrics/contributions/hourly/route.ts index 6c8740c62..ffdf11c98 100644 --- a/src/app/api/metrics/contributions/hourly/route.ts +++ b/src/app/api/metrics/contributions/hourly/route.ts @@ -19,7 +19,7 @@ export async function GET(req: NextRequest) { const daysParam = req.nextUrl.searchParams.get("days"); const parsedDays = daysParam ? parseInt(daysParam, 10) : NaN; - const days = isNaN(parsedDays) ? 30 : Math.max(1, Math.min(365, parsedDays)); + const days = Number.isNaN(parsedDays) ? 30 : Math.max(1, Math.min(365, parsedDays)); const bypass = isMetricsCacheBypassed(req); const key = metricsCacheKey( session.githubId ?? session.githubLogin, diff --git a/src/app/api/metrics/contributions/route.ts b/src/app/api/metrics/contributions/route.ts index 225440241..ed17262c5 100644 --- a/src/app/api/metrics/contributions/route.ts +++ b/src/app/api/metrics/contributions/route.ts @@ -155,7 +155,7 @@ async function fetchContributionsForAccount( if (orgName) { q += ` org:${orgName}`; } else if (excludedOrgs.length > 0) { - q += excludedOrgs.map((org) => ` -org:${org}`).join(""); + q += (excludedOrgs ?? []).map((org) => ` -org:${org}`).join(""); } // Note: this may issue up to 10 sequential GitHub Search API calls (max 1000 results). @@ -383,7 +383,7 @@ export async function GET(req: NextRequest) { } else { const daysParam = req.nextUrl.searchParams.get("days"); const parsedDays = daysParam ? parseInt(daysParam, 10) : NaN; - days = isNaN(parsedDays) ? 30 : Math.max(1, Math.min(365, parsedDays)); + days = Number.isNaN(parsedDays) ? 30 : Math.max(1, Math.min(365, parsedDays)); } const accountId = req.nextUrl.searchParams.get("accountId"); diff --git a/src/app/api/metrics/productive-hours/route.ts b/src/app/api/metrics/productive-hours/route.ts index 5bb62d383..1c73e77af 100644 --- a/src/app/api/metrics/productive-hours/route.ts +++ b/src/app/api/metrics/productive-hours/route.ts @@ -223,7 +223,7 @@ export async function GET(req: NextRequest) { } else { const daysParam = searchParams.get("days"); const parsedDays = daysParam ? parseInt(daysParam, 10) : NaN; - days = isNaN(parsedDays) ? 90 : Math.max(1, Math.min(365, parsedDays)); + days = Number.isNaN(parsedDays) ? 90 : Math.max(1, Math.min(365, parsedDays)); } const accountId = searchParams.get("accountId"); @@ -268,7 +268,7 @@ export async function GET(req: NextRequest) { ); const results = await Promise.allSettled( - accounts.map((account) => + (accounts ?? []).map((account) => fetchProductiveHoursForAccount( account.token, account.githubLogin, diff --git a/src/app/api/metrics/repos/route.ts b/src/app/api/metrics/repos/route.ts index 11ef12f67..e703bf9f1 100644 --- a/src/app/api/metrics/repos/route.ts +++ b/src/app/api/metrics/repos/route.ts @@ -145,7 +145,7 @@ async function fetchReposForAccount( if (orgName) { q += `+org:${orgName}`; } else if (excludedOrgs.length > 0) { - q += excludedOrgs.map((org) => `+-org:${org}`).join(""); + q += (excludedOrgs ?? []).map((org) => `+-org:${org}`).join(""); } q += `+author-date:>=${sinceStr}`; @@ -238,7 +238,7 @@ export async function GET(req: NextRequest) { const daysParam = req.nextUrl.searchParams.get("days"); const parsedDays = daysParam ? parseInt(daysParam, 10) : NaN; // Clamp days between 1 and 365 — GitHub Commit Search supports up to ~1 year lookback. - const days = isNaN(parsedDays) ? 30 : Math.max(1, Math.min(365, parsedDays)); + const days = Number.isNaN(parsedDays) ? 30 : Math.max(1, Math.min(365, parsedDays)); const accountId = req.nextUrl.searchParams.get("accountId"); const bypass = isMetricsCacheBypassed(req);