Skip to content

feat(iter-11): ship-wheel spinner, progressive hints, risk scorecard & YoY growth levels - #25

Merged
martinl5 merged 1 commit into
mainfrom
lcb-evolution/risk-scorecard-yoy-hint-system
Jun 26, 2026
Merged

feat(iter-11): ship-wheel spinner, progressive hints, risk scorecard & YoY growth levels#25
martinl5 merged 1 commit into
mainfrom
lcb-evolution/risk-scorecard-yoy-hint-system

Conversation

@martinl5

Copy link
Copy Markdown
Owner

[UI/UX Improvements]

Ship-wheel loading spinner (GameProvider.tsx):

  • Replaced the flat shimmer-bar + 🦁 loading screen with an animated SVG maritime ship's helm.
  • 8-spoke wheel geometry computed inline via SPOKE_ANGLES.map() (hub r=5.5, spoke tips at r=21, knob circles r=2.8 at r=24, outer rim r=24).
  • Rotates at 3 s/revolution via @keyframes spinWheel; no external asset dependency.
  • aria-hidden="true" since adjacent text describes the loading state.
  • Directly implements the "ship-wheel / compass loading spinners" item from the UI/UX rotation list.

Progressive hint disclosure (SQLPanel.tsx):

  • A splitHint() helper splits each level's hint at . boundaries into ≤ 3 progressive chunks (longer hints are grouped into thirds).
  • After a first failed submission, a gold 💡 Request hint button appears in place of the full hint text.
  • Each click reveals one additional chunk; earlier chunks fade to 70% opacity to de-emphasise them.
  • Button label changes to Show more hint (N step(s) remaining) after the first reveal.
  • hintChunkIdx state resets to 0 on every level change.
  • Changes the cognitive posture from passive delivery to active retrieval — a known pedagogical improvement for self-regulated learning.

[Game Design Tweaks]

Level 70 (Expert, difficulty 4) — "Loan Book Risk Scorecard — Weighted Rate & Running Exposure":
Four senior-DS patterns in a single challenge:

  1. Weighted-average rate: ROUND(SUM(principal_amount * interest_rate) / SUM(principal_amount), 2) — correct way to aggregate differing rates by volume (wrong: AVG(interest_rate)).
  2. Scalar CTE cross-join: a second total CTE feeds the grand total into the final SELECT via CROSS JOIN — the idiomatic pattern when you need a scalar aggregate alongside window functions.
  3. Portfolio percentage: ROUND(100.0 * g.total_principal / t.grand_total, 1).
  4. Running cumulative exposure: SUM(g.total_principal) OVER (ORDER BY g.risk_grade ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW).

Result: 3 rows (A: $1.88M, 86.5%, cumulative $1.88M | B: $245K, 11.3%, cumulative $2.13M | C: $48K, 2.2%, cumulative $2.17M). Pattern mirrors Basel III RWA dashboards at GIC, JPMorgan, DBS.

Level 71 (Expert, difficulty 4) — "Loan Portfolio Year-over-Year Disbursement Growth":

  • CTE yearly: GROUP BY STRFTIME('%Y', start_date) → loan_count, total_disbursed (all statuses — disbursement is a historical fact).
  • CTE with_lag: LAG(total_disbursed) OVER (ORDER BY loan_year) AS prev_disbursed.
  • Outer: CASE WHEN prev_disbursed IS NULL THEN NULL ELSE ROUND(100.0*(total_disbursed - prev_disbursed)/prev_disbursed, 1) END AS yoy_growth_pct.
  • 7 rows (2018–2024): +100% in 2020, −71.4% in 2021, +172.5% in 2022, −87.2% in 2023 — authentic variation that makes the pedagogical point.
  • The LAG → CASE WHEN NULL pattern is the canonical SQL idiom for period-over-period growth used in investor reports and loan-book analytics.

[Database & Code Optimizations]

  • LevelUpModal EPOCH_NEXT_HINT map extended for levels 70 and 71; nextHintKey sentinel array extended to […, 69, 70, 71]; fallback updated ?? 69?? 71.
  • MAX_LEVEL in progression.ts auto-derives from levels[levels.length - 1].id = 71 — no other touch points needed.
  • No new DB tables, seed rows, or indexes — both levels run against the existing loans table.
  • evolution_log.md updated with full iteration-11 entry.

Test Results

Test Files  5 passed (5)
     Tests  395 passed (395)   ← up from 375 in iter-10 (20 new auto-coverage cases for levels 70-71)
  Duration  944ms

npm ci ✅ · tsc --noEmit ✅ · eslint ✅ · vitest run ✅ (395/395)


Generated by Claude Code

…& YoY growth levels

UI/UX:
- Replace loading shimmer bar with rotating SVG ship-wheel helm (8 spokes, rim
  knobs, 3 s/rev spinWheel animation) — implements the rotation-list spinner item
- Progressive hint disclosure: splitHint() chunks each level's hint into ≤3 parts;
  a Request-hint button replaces auto-display; each click reveals one more chunk
  with earlier chunks fading to 70% opacity; hintChunkIdx resets on level change

Game Design:
- Level 70 (Expert/4): Loan Book Risk Scorecard — weighted-average rate via
  SUM(x*w)/SUM(w), scalar CROSS JOIN CTE for grand total, portfolio_pct, and
  running cumulative_exposure window function; 3-row A/B/C result
- Level 71 (Expert/4): Loan Portfolio YoY Disbursement Growth — STRFTIME year
  grouping, LAG for prev year, CASE WHEN NULL for first-year NULL handling; 7 rows

DB & Code:
- LevelUpModal hint map extended for levels 70-71; nextHintKey sentinel updated to 71
- MAX_LEVEL auto-derives to 71; 395 tests pass (20 more than iter-10)
- No new tables, seed rows, or indexes — both levels use existing loans table
@vercel

vercel Bot commented Jun 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sqlwak Ready Ready Preview, Comment Jun 22, 2026 5:20pm

@martinl5
martinl5 marked this pull request as ready for review June 26, 2026 14:06
@martinl5
martinl5 merged commit d7e4d1b into main Jun 26, 2026
3 checks passed
@martinl5
martinl5 deleted the lcb-evolution/risk-scorecard-yoy-hint-system branch June 26, 2026 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants