This repository has been archived on 2026-05-06. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
tippspiel/backend/src/db/migration_002.sql
T
Ronny Mueller e27a62a37b feat: Stadium Elite Design, Rangliste, Profil-Team, User-Upsert & n8n Cronjob
- MatchCard + TipModal: Uhrzeit statt VS zwischen Flaggen, Gruppe zentriert
- LeaderboardPage: Podium (2./1./3.), DU-Badge, Trend-Pfeile, Team-Zeile, CTA-Card
- AdminPage: Stadium Elite Redesign mit Result-Bar und Inline-Spinner
- ProfilePage: Team-Feld inline editierbar (PATCH /api/profile/team)
- User-Upsert beim ersten App-Aufruf (Matches-Route) statt erst beim Tipp
- DB Migration 002: team-Spalte in users, Leaderboard View aktualisiert
- Leaderboard-Refresh automatisch nach Tipps-Auswertung
- n8n Workflow angelegt: stündlicher Sync + Auswertung (ID: t3SDspIGDXwkfOt3)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 23:37:38 +02:00

22 lines
822 B
SQL

-- Migration 002: Add team field to users table
ALTER TABLE users ADD COLUMN IF NOT EXISTS team TEXT;
-- Refresh leaderboard view to include team
DROP MATERIALIZED VIEW IF EXISTS leaderboard;
CREATE MATERIALIZED VIEW leaderboard AS
SELECT
u.id AS user_id,
u.full_name,
u.team,
RANK() OVER (ORDER BY COALESCE(SUM(t.points), 0) DESC) AS rank,
COALESCE(SUM(t.points), 0) AS total_points,
COUNT(t.id) FILTER (WHERE t.points IS NOT NULL) AS tips_count,
COUNT(t.id) FILTER (WHERE t.points = 3) AS exact_count,
COUNT(t.id) FILTER (WHERE t.points = 1) AS tendency_count
FROM users u
LEFT JOIN tips t ON t.user_id = u.id
GROUP BY u.id, u.full_name, u.team;
CREATE UNIQUE INDEX IF NOT EXISTS leaderboard_user_id_idx ON leaderboard (user_id);