diff --git a/README.md b/README.md index 5f959cd..9832e16 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,9 @@ Das Projekt ist für den Betrieb mit Docker optimiert. ```bash cp docker-compose.example.yml docker-compose.yml ``` - Passe ggf. das `ADMIN_PASSWORD` in der `docker-compose.yml` an. + Passe die Umgebungsvariablen in der `docker-compose.yml` an: + - `ADMIN_PASSWORD`: Admin-Passwort (Standard: `admin123`) + - `TZ`: Zeitzone für täglichen Puzzle-Wechsel (Standard: `Europe/Berlin`) 2. **Starten:** ```bash diff --git a/app/api/daily/route.ts b/app/api/daily/route.ts index 97a234f..85affeb 100644 --- a/app/api/daily/route.ts +++ b/app/api/daily/route.ts @@ -5,13 +5,22 @@ const prisma = new PrismaClient(); export async function GET() { try { - const today = new Date().toISOString().split('T')[0]; + // Use timezone from environment variable (default: Europe/Berlin) + const timezone = process.env.TZ || 'Europe/Berlin'; + const today = new Date().toLocaleDateString('en-CA', { + timeZone: timezone, + year: 'numeric', + month: '2-digit', + day: '2-digit' + }); // Format: "2025-11-21" let dailyPuzzle = await prisma.dailyPuzzle.findUnique({ where: { date: today }, include: { song: true }, }); + console.log(`[Daily Puzzle] Date: ${today}, Found existing: ${!!dailyPuzzle}`); + if (!dailyPuzzle) { // Get all songs with their usage count const allSongs = await prisma.song.findMany({ @@ -54,6 +63,8 @@ export async function GET() { }, include: { song: true }, }); + + console.log(`[Daily Puzzle] Created new puzzle for ${today} with song: ${selectedSong.title} (ID: ${selectedSong.id})`); } if (!dailyPuzzle) { @@ -63,7 +74,10 @@ export async function GET() { return NextResponse.json({ id: dailyPuzzle.id, audioUrl: `/uploads/${dailyPuzzle.song.filename}`, - songId: dailyPuzzle.songId + songId: dailyPuzzle.songId, + title: dailyPuzzle.song.title, + artist: dailyPuzzle.song.artist, + coverImage: dailyPuzzle.song.coverImage ? `/uploads/covers/${dailyPuzzle.song.coverImage}` : null, }); } catch (error) { diff --git a/docker-compose.example.yml b/docker-compose.example.yml index 2e7bcf3..17ab75a 100644 --- a/docker-compose.example.yml +++ b/docker-compose.example.yml @@ -11,6 +11,7 @@ services: environment: - DATABASE_URL=file:/app/data/prod.db - ADMIN_PASSWORD=admin123 # Change this! + - TZ=Europe/Berlin # Timezone for daily puzzle rotation volumes: - ./data:/app/data - ./public/uploads:/app/public/uploads