Skip to content

feat(iter-14): rank promotion banner, WITH RECURSIVE date spine & FIRST_VALUE/LAST_VALUE levels - #28

Merged
martinl5 merged 1 commit into
mainfrom
lcb-evolution/rank-promotion-recursive-firstlast
Jul 14, 2026
Merged

feat(iter-14): rank promotion banner, WITH RECURSIVE date spine & FIRST_VALUE/LAST_VALUE levels#28
martinl5 merged 1 commit into
mainfrom
lcb-evolution/rank-promotion-recursive-firstlast

Conversation

@martinl5

Copy link
Copy Markdown
Owner

Summary

  • Rank Promotion Banner — spring-animated maritime toast when XP crosses a career-rank threshold (Graduate Analyst → Senior Analyst → VP → Managing Director)
  • Level 76 — Monthly Revenue Completeness Check: first use of WITH RECURSIVE date spine + LEFT JOIN zero-fill
  • Level 77 — Fleet Voyage Bookends: FIRST_VALUE + LAST_VALUE with the critical explicit window-frame gotcha

[UI/UX Improvements]

RankPromotionBanner.tsx (new component, wired into GameProvider.tsx):

The career-rank ladder (Graduate Analyst → Senior Analyst → VP, Data & Analytics → Managing Director) has been reachable since iter-7, but crossing a threshold produced no feedback. This PR adds the missing signal.

  • Spring entrance animation (stiffness 320, damping 26) slides the card down from 80 px above viewport; exits the same way.
  • Gold top accent stripe + deep shadow give depth without obscuring gameplay.
  • Rank-specific icon (⚓ / 🧭 / 🏅) spins 720° on entry — one deliberate motion moment, not ambient noise.
  • 6-second auto-dismiss with depleting gold countdown bar; dismiss × button and click-anywhere also close it.
  • Each rank has bespoke maritime flavour text tied to the SQL skills just demonstrated.
  • Detection via useRef tracking previous rank name in GameProvider — fires only when rank name changes after the initial render (no spurious trigger on load).

Implements the "gamification: rank tiers" rotation item.

[Game Design Tweaks]

Level 76 (Expert, difficulty 4) — "Monthly Revenue Completeness Check (WITH RECURSIVE)":

  • First WITH RECURSIVE level in the catalog — teaches iterative CTEs as a SQL primitive
  • Recursive CTE months(month) seeds at '2024-01', advances via STRFTIME('%Y-%m', DATE(month || '-01', '+1 month')), terminates at '2024-06'
  • LEFT JOIN to actual monthly cargo revenue with COALESCE zero-fill and status flag
  • Returns 6 rows (all Active — data is complete, proving the guard works)
  • Pedagogical point: GROUP BY silently hides zero-activity periods; date spines surface gaps explicitly
  • Pattern used in Looker, Redshift/Snowflake time-spine logic, and MAS reporting gap-detection pipelines

Level 77 (Expert, difficulty 4) — "Fleet Voyage Bookends (FIRST_VALUE + LAST_VALUE)":

  • Teaches FIRST_VALUE and LAST_VALUE with the window-frame gotcha: LAST_VALUE default frame RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW returns the current row's value, not the partition's last — requires explicit ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
  • Single CTE voyage_data computes all four window expressions together; outer query deduplicates with WHERE rn = 1
  • Returns 12 rows — one per vessel. 7 vessels show first_origin ≠ last_origin (routing evolution visible); 5 show matching bookends (consistent homebase)
  • Pattern appears in FAANG DS interviews, trading-desk settlement-gap analysis, and logistics routing pipelines

[Database & Code Optimizations]

  • LevelUpModal hint map extended with entries for levels 76 and 77; nextHintKey sentinel extended to […, 75, 76, 77]; fallback updated ?? 75?? 77
  • MAX_LEVEL auto-derives from levels[levels.length - 1].id (77) — no other touch points
  • No new DB tables, seed rows, or indexes

Test Results

  • npm ci — ✅ installed (pre-existing vulnerabilities, none introduced)
  • npx tsc --noEmit — ✅ 0 errors
  • npm test — ✅ 425 tests pass (up from 415 in iter-13; both new levels auto-picked up by determinism invariants suite)

Generated by Claude Code

…ST_VALUE/LAST_VALUE levels

- RankPromotionBanner: spring-animated toast when XP crosses rank thresholds
- Level 76: date spine via WITH RECURSIVE + LEFT JOIN zero-fill (completeness check)
- Level 77: fleet voyage bookends using FIRST_VALUE + LAST_VALUE with explicit window frame
@vercel

vercel Bot commented Jul 13, 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 Jul 13, 2026 5:18pm

@martinl5
martinl5 marked this pull request as ready for review July 14, 2026 09:23
@martinl5
martinl5 merged commit 2bdbca3 into main Jul 14, 2026
2 of 3 checks passed
@martinl5
martinl5 deleted the lcb-evolution/rank-promotion-recursive-firstlast branch July 14, 2026 09:23
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