Compare commits
8 Commits
e2bdf0fc88
...
v0.1.5.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
71abb7c322 | ||
|
|
b730c6637a | ||
|
|
6e93529bc3 | ||
|
|
990e1927e9 | ||
|
|
d7fee047c2 | ||
|
|
28d14ff099 | ||
|
|
b1493b44bf | ||
|
|
b8a803b76e |
@@ -103,9 +103,11 @@ export async function GET(request: NextRequest) {
|
|||||||
|
|
||||||
visibleSongs = songs.filter(song => {
|
visibleSongs = songs.filter(song => {
|
||||||
const songGenreIds = song.genres.map(g => g.id);
|
const songGenreIds = song.genres.map(g => g.id);
|
||||||
// `song.specials` ist hier ein Array von SpecialSong mit Relation `special`,
|
// `song.specials` ist hier ein Array von SpecialSong mit Relation `special`.
|
||||||
// wir nutzen konsistent die Special-ID.
|
// Es kann theoretisch verwaiste Einträge ohne `special` geben → defensiv optional chainen.
|
||||||
const songSpecialIds = song.specials.map(ss => ss.special.id);
|
const songSpecialIds = song.specials
|
||||||
|
.map(ss => ss.special?.id)
|
||||||
|
.filter((id): id is number => typeof id === 'number');
|
||||||
|
|
||||||
// Songs ohne Genres/Specials sind immer sichtbar
|
// Songs ohne Genres/Specials sind immer sichtbar
|
||||||
if (songGenreIds.length === 0 && songSpecialIds.length === 0) {
|
if (songGenreIds.length === 0 && songSpecialIds.length === 0) {
|
||||||
@@ -131,7 +133,10 @@ export async function GET(request: NextRequest) {
|
|||||||
activations: song.puzzles.length,
|
activations: song.puzzles.length,
|
||||||
puzzles: song.puzzles,
|
puzzles: song.puzzles,
|
||||||
genres: song.genres,
|
genres: song.genres,
|
||||||
specials: song.specials.map(ss => ss.special),
|
// Nur Specials mit existierender Relation durchreichen, um undefinierte Einträge zu vermeiden.
|
||||||
|
specials: song.specials
|
||||||
|
.map(ss => ss.special)
|
||||||
|
.filter((s): s is any => !!s),
|
||||||
averageRating: song.averageRating,
|
averageRating: song.averageRating,
|
||||||
ratingCount: song.ratingCount,
|
ratingCount: song.ratingCount,
|
||||||
excludeFromGlobal: song.excludeFromGlobal,
|
excludeFromGlobal: song.excludeFromGlobal,
|
||||||
|
|||||||
1333
app/curator/CuratorPageClient.tsx
Normal file
1333
app/curator/CuratorPageClient.tsx
Normal file
File diff suppressed because it is too large
Load Diff
1331
app/curator/page.tsx
1331
app/curator/page.tsx
File diff suppressed because it is too large
Load Diff
@@ -519,14 +519,20 @@ export default function Game({ dailyPuzzle, genre = null, isSpecial = false, max
|
|||||||
</audio>
|
</audio>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style={{ marginBottom: '1rem' }}>
|
<div style={{ marginBottom: '1.25rem' }}>
|
||||||
<StarRating onRate={handleRatingSubmit} hasRated={hasRated} />
|
<StarRating onRate={handleRatingSubmit} hasRated={hasRated} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div style={{ marginBottom: '1.25rem', textAlign: 'center' }}>
|
||||||
|
<p style={{ fontSize: '0.85rem', color: 'var(--muted-foreground)', marginBottom: '0.5rem' }}>
|
||||||
|
{t('shareExplanation')}
|
||||||
|
</p>
|
||||||
|
<button onClick={handleShare} className="btn-primary">
|
||||||
|
{shareText}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
{statistics && <Statistics statistics={statistics} />}
|
{statistics && <Statistics statistics={statistics} />}
|
||||||
<button onClick={handleShare} className="btn-primary" style={{ marginTop: '1rem' }}>
|
|
||||||
{shareText}
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
@@ -49,13 +49,15 @@ export async function getOrCreateDailyPuzzle(genre: Genre | null = null) {
|
|||||||
// Calculate total weight
|
// Calculate total weight
|
||||||
const totalWeight = weightedSongs.reduce((sum, item) => sum + item.weight, 0);
|
const totalWeight = weightedSongs.reduce((sum, item) => sum + item.weight, 0);
|
||||||
|
|
||||||
// Pick a random song based on weights
|
// Pick a random song based on weights using cumulative weights
|
||||||
|
// This ensures proper distribution and handles edge cases
|
||||||
let random = Math.random() * totalWeight;
|
let random = Math.random() * totalWeight;
|
||||||
let selectedSong = weightedSongs[0].song;
|
let selectedSong = weightedSongs[weightedSongs.length - 1].song; // Fallback to last song
|
||||||
|
|
||||||
|
let cumulativeWeight = 0;
|
||||||
for (const item of weightedSongs) {
|
for (const item of weightedSongs) {
|
||||||
random -= item.weight;
|
cumulativeWeight += item.weight;
|
||||||
if (random <= 0) {
|
if (random <= cumulativeWeight) {
|
||||||
selectedSong = item.song;
|
selectedSong = item.song;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -156,11 +158,13 @@ export async function getOrCreateSpecialPuzzle(special: Special) {
|
|||||||
|
|
||||||
const totalWeight = weightedSongs.reduce((sum, item) => sum + item.weight, 0);
|
const totalWeight = weightedSongs.reduce((sum, item) => sum + item.weight, 0);
|
||||||
let random = Math.random() * totalWeight;
|
let random = Math.random() * totalWeight;
|
||||||
let selectedSpecialSong = weightedSongs[0].specialSong;
|
let selectedSpecialSong = weightedSongs[weightedSongs.length - 1].specialSong; // Fallback to last song
|
||||||
|
|
||||||
|
// Pick a random song based on weights using cumulative weights
|
||||||
|
let cumulativeWeight = 0;
|
||||||
for (const item of weightedSongs) {
|
for (const item of weightedSongs) {
|
||||||
random -= item.weight;
|
cumulativeWeight += item.weight;
|
||||||
if (random <= 0) {
|
if (random <= cumulativeWeight) {
|
||||||
selectedSpecialSong = item.specialSong;
|
selectedSpecialSong = item.specialSong;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
"comeBackTomorrow": "Komm morgen zurück für ein neues Lied.",
|
"comeBackTomorrow": "Komm morgen zurück für ein neues Lied.",
|
||||||
"theSongWas": "Das Lied war:",
|
"theSongWas": "Das Lied war:",
|
||||||
"score": "Punkte",
|
"score": "Punkte",
|
||||||
|
"shareExplanation": "Teile dein Ergebnis mit Freund:innen – so hilfst du, Hördle bekannter zu machen.",
|
||||||
"scoreBreakdown": "Punkteaufschlüsselung",
|
"scoreBreakdown": "Punkteaufschlüsselung",
|
||||||
"albumCover": "Album-Cover",
|
"albumCover": "Album-Cover",
|
||||||
"released": "Veröffentlicht",
|
"released": "Veröffentlicht",
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
"comeBackTomorrow": "Come back tomorrow for a new song.",
|
"comeBackTomorrow": "Come back tomorrow for a new song.",
|
||||||
"theSongWas": "The song was:",
|
"theSongWas": "The song was:",
|
||||||
"score": "Score",
|
"score": "Score",
|
||||||
|
"shareExplanation": "Share your result with friends – your support helps Hördle grow.",
|
||||||
"scoreBreakdown": "Score Breakdown",
|
"scoreBreakdown": "Score Breakdown",
|
||||||
"albumCover": "Album Cover",
|
"albumCover": "Album Cover",
|
||||||
"released": "Released",
|
"released": "Released",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hoerdle",
|
"name": "hoerdle",
|
||||||
"version": "0.1.4.11",
|
"version": "0.1.5.1",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev",
|
"dev": "next dev",
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo "🚀 Starting optimized deployment..."
|
echo "🚀 Starting optimized deployment with full rollback support..."
|
||||||
|
|
||||||
# Backup database
|
# Backup database (per Deployment, inkl. Metadaten für Rollback)
|
||||||
echo "💾 Creating database backup..."
|
echo "💾 Creating database backup for this deployment..."
|
||||||
|
|
||||||
# Try to find database path from docker-compose.yml or .env
|
# Try to find database path from docker-compose.yml or .env
|
||||||
DB_PATH=""
|
DB_PATH=""
|
||||||
@@ -26,16 +26,29 @@ if [ -n "$DB_PATH" ]; then
|
|||||||
# Convert container path to host path if needed
|
# Convert container path to host path if needed
|
||||||
# /app/data/prod.db -> ./data/prod.db
|
# /app/data/prod.db -> ./data/prod.db
|
||||||
DB_PATH=$(echo "$DB_PATH" | sed 's|/app/|./|')
|
DB_PATH=$(echo "$DB_PATH" | sed 's|/app/|./|')
|
||||||
|
|
||||||
if [ -f "$DB_PATH" ]; then
|
if [ -f "$DB_PATH" ]; then
|
||||||
# Create backups directory
|
# Create backups directory
|
||||||
mkdir -p ./backups
|
mkdir -p ./backups
|
||||||
|
|
||||||
# Create timestamped backup
|
# Create timestamped backup
|
||||||
BACKUP_FILE="./backups/$(basename "$DB_PATH" .db)_$(date +%Y%m%d_%H%M%S).db"
|
DEPLOY_TS="$(date +%Y%m%d_%H%M%S)"
|
||||||
|
BACKUP_FILE="./backups/$(basename "$DB_PATH" .db)_${DEPLOY_TS}.db"
|
||||||
cp "$DB_PATH" "$BACKUP_FILE"
|
cp "$DB_PATH" "$BACKUP_FILE"
|
||||||
echo "✅ Database backed up to: $BACKUP_FILE"
|
echo "✅ Database backed up to: $BACKUP_FILE"
|
||||||
|
|
||||||
|
# Store metadata for restore (Timestamp, DB-Path, Git-Commit)
|
||||||
|
CURRENT_COMMIT="$(git rev-parse HEAD || echo 'unknown')"
|
||||||
|
{
|
||||||
|
echo "timestamp=${DEPLOY_TS}"
|
||||||
|
echo "db_path=${DB_PATH}"
|
||||||
|
echo "backup_file=${BACKUP_FILE}"
|
||||||
|
echo "git_commit=${CURRENT_COMMIT}"
|
||||||
|
} > "./backups/last_deploy.meta"
|
||||||
|
|
||||||
|
# Append to history manifest (eine Zeile pro Deployment)
|
||||||
|
echo "${DEPLOY_TS}|${DB_PATH}|${BACKUP_FILE}|${CURRENT_COMMIT}" >> "./backups/deploy_history.log"
|
||||||
|
|
||||||
# Keep only last 10 backups
|
# Keep only last 10 backups
|
||||||
ls -t ./backups/*.db | tail -n +11 | xargs -r rm
|
ls -t ./backups/*.db | tail -n +11 | xargs -r rm
|
||||||
echo "🧹 Cleaned old backups (keeping last 10)"
|
echo "🧹 Cleaned old backups (keeping last 10)"
|
||||||
@@ -46,13 +59,10 @@ else
|
|||||||
echo "⚠️ Could not determine database path from config files"
|
echo "⚠️ Could not determine database path from config files"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Pull latest changes
|
# Nur neueste Version holen (shallow fetch), vollständiges Repo ist im Deployment nicht nötig
|
||||||
echo "📥 Pulling latest changes from git..."
|
echo "📥 Fetching latest commit (shallow clone) from git..."
|
||||||
git pull
|
git fetch --prune --tags --depth=1 origin master
|
||||||
|
git reset --hard origin/master
|
||||||
# Fetch all tags
|
|
||||||
echo "🏷️ Fetching git tags..."
|
|
||||||
git fetch --tags
|
|
||||||
|
|
||||||
# Prüfe und erstelle/repariere Netzwerk falls nötig
|
# Prüfe und erstelle/repariere Netzwerk falls nötig
|
||||||
echo "🌐 Prüfe Docker-Netzwerk..."
|
echo "🌐 Prüfe Docker-Netzwerk..."
|
||||||
|
|||||||
93
scripts/restore.sh
Normal file
93
scripts/restore.sh
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "🧯 Hördle restore script – Rollback auf früheres Datenbank-Backup"
|
||||||
|
|
||||||
|
# Hilfsfunktion für Fehlerausgabe
|
||||||
|
die() {
|
||||||
|
echo "❌ $1" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Backup-Verzeichnis
|
||||||
|
BACKUP_DIR="./backups"
|
||||||
|
|
||||||
|
if [ ! -d "$BACKUP_DIR" ]; then
|
||||||
|
die "Kein Backup-Verzeichnis gefunden (${BACKUP_DIR}). Es scheint noch kein Deployment-Backup erstellt worden zu sein."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Argument: gewünschter Backup-Timestamp oder 'latest'
|
||||||
|
TARGET="$1"
|
||||||
|
|
||||||
|
if [ -z "$TARGET" ]; then
|
||||||
|
echo "⚙️ Nutzung:"
|
||||||
|
echo " ./scripts/restore.sh latest # neuestes Backup zurückspielen"
|
||||||
|
echo " ./scripts/restore.sh 20250101_120000 # bestimmtes Backup (Timestamp aus Dateiname)"
|
||||||
|
echo ""
|
||||||
|
echo "Verfügbare Backups:"
|
||||||
|
ls -1 "${BACKUP_DIR}"/*.db 2>/dev/null || echo " (keine .db-Backups gefunden)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# DB-Pfad wie in deploy.sh bestimmen
|
||||||
|
DB_PATH=""
|
||||||
|
|
||||||
|
if [ -f "docker-compose.yml" ]; then
|
||||||
|
DB_PATH=$(grep -oP 'DATABASE_URL=file:\K[^\s]+' docker-compose.yml | head -1)
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$DB_PATH" ] && [ -f ".env" ]; then
|
||||||
|
DB_PATH=$(grep -oP '^DATABASE_URL=file:\K.+' .env | head -1)
|
||||||
|
fi
|
||||||
|
|
||||||
|
DB_PATH=$(echo "$DB_PATH" | tr -d '"' | tr -d "'")
|
||||||
|
|
||||||
|
if [ -z "$DB_PATH" ]; then
|
||||||
|
die "Konnte den Datenbank-Pfad aus docker-compose.yml oder .env nicht ermitteln."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Containerpfad zu Hostpfad umbauen (/app/... -> ./...)
|
||||||
|
DB_PATH=$(echo "$DB_PATH" | sed 's|/app/|./|')
|
||||||
|
|
||||||
|
echo "📁 Ziel-Datenbank-Datei: $DB_PATH"
|
||||||
|
|
||||||
|
# Backup-Datei bestimmen
|
||||||
|
if [ "$TARGET" = "latest" ]; then
|
||||||
|
BACKUP_FILE=$(ls -t "${BACKUP_DIR}"/*.db 2>/dev/null | head -1 || true)
|
||||||
|
[ -z "$BACKUP_FILE" ] && die "Kein Backup gefunden."
|
||||||
|
else
|
||||||
|
# Versuchen, exakten Dateinamen zu finden
|
||||||
|
if [ -f "${BACKUP_DIR}/${TARGET}" ]; then
|
||||||
|
BACKUP_FILE="${BACKUP_DIR}/${TARGET}"
|
||||||
|
else
|
||||||
|
# Versuchen, anhand des Timestamps ein Backup zu finden
|
||||||
|
BACKUP_FILE=$(ls "${BACKUP_DIR}"/*"${TARGET}"*.db 2>/dev/null | head -1 || true)
|
||||||
|
fi
|
||||||
|
|
||||||
|
[ -z "$BACKUP_FILE" ] && die "Kein Backup für '${TARGET}' gefunden."
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "⏪ Verwende Backup-Datei: $BACKUP_FILE"
|
||||||
|
|
||||||
|
if [ ! -f "$BACKUP_FILE" ]; then
|
||||||
|
die "Backup-Datei existiert nicht: $BACKUP_FILE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
read -p "❗ Dies überschreibt die aktuelle Datenbank-Datei. Fortfahren? [y/N] " CONFIRM
|
||||||
|
if [[ ! "$CONFIRM" =~ ^[Yy]$ ]]; then
|
||||||
|
echo "Abgebrochen."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "📦 Kopiere Backup nach: $DB_PATH"
|
||||||
|
cp "$BACKUP_FILE" "$DB_PATH"
|
||||||
|
|
||||||
|
echo "🔄 Starte Docker-Container neu..."
|
||||||
|
docker compose restart hoerdle
|
||||||
|
|
||||||
|
echo "✅ Restore abgeschlossen."
|
||||||
|
echo "ℹ️ Hinweis: Der Code-Stand (Git-Commit) ist nicht automatisch zurückgedreht."
|
||||||
|
echo " Falls du auch die App-Version zurückrollen möchtest, checke lokal den passenden Commit/Tag aus"
|
||||||
|
echo " und führe anschließend wieder ./scripts/deploy.sh aus."
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user