From a88561073a3e494405acc25161c9d1cfef3541ba Mon Sep 17 00:00:00 2001 From: shay Date: Mon, 20 Apr 2026 13:56:43 -0400 Subject: [PATCH] feat(result-screen): add onRegenerate prop to ResultScreen component. --- generator/frontend/src/App.tsx | 1 + .../frontend/src/screens/ResultScreen.tsx | 27 +++++++++++++++++-- generator/src/processor.py | 19 +++++-------- 3 files changed, 33 insertions(+), 14 deletions(-) diff --git a/generator/frontend/src/App.tsx b/generator/frontend/src/App.tsx index 59ed5a1..fd02524 100644 --- a/generator/frontend/src/App.tsx +++ b/generator/frontend/src/App.tsx @@ -278,6 +278,7 @@ export default function App() { generatedSvg={generatedSvg} generateError={generateError} onBack={handleBack} + onRegenerate={handleGenerate} /> )} diff --git a/generator/frontend/src/screens/ResultScreen.tsx b/generator/frontend/src/screens/ResultScreen.tsx index a8868d8..dc1704a 100644 --- a/generator/frontend/src/screens/ResultScreen.tsx +++ b/generator/frontend/src/screens/ResultScreen.tsx @@ -15,9 +15,10 @@ type Props = { generatedSvg: string | null generateError: string | null onBack: () => void + onRegenerate: () => void } -export function ResultScreen({ username, generating, generatedSvg, generateError, onBack }: Props) { +export function ResultScreen({ username, generating, generatedSvg, generateError, onBack, onRegenerate }: Props) { const safeSvg = useMemo(() => (generatedSvg ? sanitizeSvg(generatedSvg) : ''), [generatedSvg]) const [copied, setCopied] = useState(false) const embedUrl = `${window.location.origin}/api/${encodeURIComponent(username)}` @@ -35,7 +36,7 @@ export function ResultScreen({ username, generating, generatedSvg, generateError return (
-
+
+
diff --git a/generator/src/processor.py b/generator/src/processor.py index 424db6a..2d0253e 100644 --- a/generator/src/processor.py +++ b/generator/src/processor.py @@ -86,20 +86,15 @@ def compute_grade(github_data: dict, custom_tags: list[str] = None) -> GradeData active_weeks.add((iso[0], iso[1])) except ValueError: continue - consistency_score = min(len(active_weeks) / 40 * 100, 100) - # Weights sum to 1.0. Commits dominates (the user's actual output), - # consistency is the second-biggest (rewards sustained work over the - # last year, not just lifetime totals). Stars is softened two ways: - # its weight drops from 0.20 to 0.12, and the cap rises from 200 to - # 300 so each individual star contributes less to maxing the factor. + # Weights sum to 1.0 per_factor = { - "commits": (min(commits / 2000 * 100, 100), 0.33), - "consistency": (consistency_score, 0.22), - "repos": (min(repo_count / 30 * 100, 100), 0.15), - "stars": (min(stars / 300 * 100, 100), 0.12), - "forks": (min(forks / 50 * 100, 100), 0.08), - "activity": (min(len(events) / 80 * 100, 100), 0.07), + "commits": (min(commits / 3000 * 100, 100), 0.33), + "consistency": (min(len(active_weeks) / 40 * 100, 100), 0.22), + "repos": (min(repo_count / 40 * 100, 100), 0.15), + "stars": (min(stars / 200 * 100, 100), 0.11), + "forks": (min(forks / 20 * 100, 100), 0.08), + "activity": (min(len(events) / 80 * 100, 100), 0.08), "followers": (min(followers / 100 * 100, 100), 0.03), } scores = {k: v for k, (v, _w) in per_factor.items()}