From 23b280667d58fd03099d30f577c6531dcc4f1c60 Mon Sep 17 00:00:00 2001 From: Osama Mabkhot <99215291+O2sa@users.noreply.github.com> Date: Wed, 22 Jul 2026 02:30:25 +0300 Subject: [PATCH 1/2] feat: enable leaderboard calculation endpoint with configuration toggle --- .env.example | 3 ++- app/api/calculate-leaderboard/route.ts | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index d4343c2..3dcca8f 100644 --- a/.env.example +++ b/.env.example @@ -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 @@ -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 \ No newline at end of file +POSTGRES_PASSWORD=CHANGE_THIS_TO_A_LONG_RANDOM_PASSWORD diff --git a/app/api/calculate-leaderboard/route.ts b/app/api/calculate-leaderboard/route.ts index 02ae782..5a9c83b 100644 --- a/app/api/calculate-leaderboard/route.ts +++ b/app/api/calculate-leaderboard/route.ts @@ -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(); @@ -26,4 +39,4 @@ export async function POST(request: Request) { { status: 502 }, ); } -} \ No newline at end of file +} From 7ba267ee5a3d1294690003aab1af3ee20d755d89 Mon Sep 17 00:00:00 2001 From: Osama Mabkhot <99215291+O2sa@users.noreply.github.com> Date: Tue, 28 Jul 2026 00:22:00 +0300 Subject: [PATCH 2/2] refactor: add reusable Avatar component and integrate it into leaderboard and result dashboard --- components/avatar.tsx | 33 ++++++++++++++++++++++++++++++++ components/leaderboard-table.tsx | 8 +++----- components/result-dashboard.tsx | 20 +++++++------------ next.config.js | 1 + 4 files changed, 44 insertions(+), 18 deletions(-) create mode 100644 components/avatar.tsx diff --git a/components/avatar.tsx b/components/avatar.tsx new file mode 100644 index 0000000..95ade3b --- /dev/null +++ b/components/avatar.tsx @@ -0,0 +1,33 @@ +import Image from "next/image"; +import { cn } from "@/lib/utils"; + +type AvatarProps = { + src: string; + alt: string; + size?: number; + unoptimized?: boolean; + className?: string; +}; + +/** + * Reusable avatar image component. + * + */ +export function Avatar({ + src, + alt, + size = 32, + unoptimized = true, + className, +}: AvatarProps) { + return ( + {alt} + ); +} diff --git a/components/leaderboard-table.tsx b/components/leaderboard-table.tsx index f7872db..14ccbd2 100644 --- a/components/leaderboard-table.tsx +++ b/components/leaderboard-table.tsx @@ -1,8 +1,8 @@ "use client"; import { useState, useMemo } from "react"; -import Image from "next/image"; import { Search, AlertTriangle } from "lucide-react"; +import { Avatar } from "./avatar"; import { Tooltip, TooltipContent, TooltipTrigger } from "./ui/tooltip"; import { Card, @@ -154,12 +154,10 @@ export function LeaderboardTable({
- {user.name
- {t("comparison.avatarAlt", - {t("comparison.avatarAlt", {winnerAvatar ? ( - {t("comparison.avatarAlt", ) : null}

diff --git a/next.config.js b/next.config.js index 2e47547..3228a37 100644 --- a/next.config.js +++ b/next.config.js @@ -3,6 +3,7 @@ const nextConfig = { reactStrictMode: true, typedRoutes: true, images: { + unoptimized: true, remotePatterns: [ { protocol: "https",