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
6 changes: 3 additions & 3 deletions src/app/api/metrics/activity/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion src/app/api/metrics/contributions/hourly/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/app/api/metrics/contributions/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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");
Expand Down
4 changes: 2 additions & 2 deletions src/app/api/metrics/productive-hours/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/app/api/metrics/repos/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;

Expand Down Expand Up @@ -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);

Expand Down
Loading