Skip to content
Merged
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
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ GITHUB_DISCUSSION_COUNT=10

# Leaderboard source data
LEADERBOARD_SOURCE_URL_TEMPLATE=https://raw.githubusercontent.com/ashkulz/committers.top/gh-pages/_data/locations/{country}.yml
DISABLE_CALCULATE_LEADERBOARD_ENDPOINT=false

# Redis caching (optional — strongly recommended for leaderboard performance)
# Use either redis://localhost:6379 or include password if enabled: redis://:password@localhost:6379
Expand All @@ -24,4 +25,4 @@ REDIS_CONNECT_TIMEOUT_MS=1500

# ── PostgreSQL (local development) ─────────────────
DATABASE_URL=postgresql://devimpact:devimpact@localhost:5432/devimpact?sslmode=disable
POSTGRES_PASSWORD=CHANGE_THIS_TO_A_LONG_RANDOM_PASSWORD
POSTGRES_PASSWORD=CHANGE_THIS_TO_A_LONG_RANDOM_PASSWORD
15 changes: 14 additions & 1 deletion app/api/calculate-leaderboard/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,20 @@ import { calculateLeaderboard } from "@/lib/calculate-leaderboard";

export const runtime = "nodejs";

function isCalculateLeaderboardDisabled(): boolean {
const raw =
process.env.DISABLE_CALCULATE_LEADERBOARD_ENDPOINT?.trim().toLowerCase();
return raw === "true" || raw === "1" || raw === "yes";
}

export async function POST(request: Request) {
if (isCalculateLeaderboardDisabled()) {
return NextResponse.json(
{ success: false, error: "Not found" },
{ status: 404 },
);
}

const { searchParams } = new URL(request.url);
const country = searchParams.get("country")?.trim();

Expand All @@ -26,4 +39,4 @@ export async function POST(request: Request) {
{ status: 502 },
);
}
}
}
Loading