rating display fix & directory mapping

This commit is contained in:
Stefan Hardegger
2026-06-05 20:38:44 +02:00
parent f4ffe67505
commit ca20e54115
4 changed files with 83 additions and 15 deletions

View File

@@ -8,7 +8,7 @@ services:
ports: ports:
- "6925:80" - "6925:80"
volumes: volumes:
- images_data:/app/images:ro - /volume1/docker/storycove/images:/app/images:ro
configs: configs:
- source: nginx_config - source: nginx_config
target: /etc/nginx/nginx.conf target: /etc/nginx/nginx.conf
@@ -42,9 +42,9 @@ services:
- APP_PASSWORD=${APP_PASSWORD} - APP_PASSWORD=${APP_PASSWORD}
- STORYCOVE_CORS_ALLOWED_ORIGINS=${STORYCOVE_CORS_ALLOWED_ORIGINS:-http://localhost:3000,http://localhost:6925} - STORYCOVE_CORS_ALLOWED_ORIGINS=${STORYCOVE_CORS_ALLOWED_ORIGINS:-http://localhost:3000,http://localhost:6925}
volumes: volumes:
- images_data:/app/images - /volume1/docker/storycove/images:/app/images
- library_config:/app/config - /volume1/docker/storycove/config:/app/config
- automatic_backups:/app/automatic-backups - /volume1/docker/storycove/backups:/app/automatic-backups
depends_on: depends_on:
postgres: postgres:
condition: service_healthy condition: service_healthy
@@ -63,7 +63,7 @@ services:
- POSTGRES_USER=storycove - POSTGRES_USER=storycove
- POSTGRES_PASSWORD=${DB_PASSWORD} - POSTGRES_PASSWORD=${DB_PASSWORD}
volumes: volumes:
- postgres_data:/var/lib/postgresql/data - /volume1/docker/storycove/postgres:/var/lib/postgresql/data
networks: networks:
- storycove-network - storycove-network
healthcheck: healthcheck:
@@ -83,7 +83,7 @@ services:
- SOLR_HEAP=512m - SOLR_HEAP=512m
- SOLR_JAVA_MEM=-Xms256m -Xmx512m - SOLR_JAVA_MEM=-Xms256m -Xmx512m
volumes: volumes:
- solr_data:/var/solr - /volume1/docker/storycove/solr:/var/solr
deploy: deploy:
resources: resources:
limits: limits:
@@ -102,13 +102,6 @@ services:
restart: unless-stopped restart: unless-stopped
volumes:
postgres_data:
solr_data:
images_data:
library_config:
automatic_backups:
configs: configs:
nginx_config: nginx_config:
content: | content: |

View File

@@ -1,6 +1,6 @@
'use client'; 'use client';
import { useState } from 'react'; import { useState, useEffect } from 'react';
import Link from 'next/link'; import Link from 'next/link';
import Image from 'next/image'; import Image from 'next/image';
import { Story } from '../../types/api'; import { Story } from '../../types/api';
@@ -49,6 +49,12 @@ export default function StoryCard({
const [rating, setRating] = useState(story.rating || 0); const [rating, setRating] = useState(story.rating || 0);
const [updating, setUpdating] = useState(false); const [updating, setUpdating] = useState(false);
// Sync rating state when a different story is rendered in the same component slot,
// or when the story's rating is updated externally (e.g. from the detail page).
useEffect(() => {
setRating(story.rating || 0);
}, [story.id, story.rating]);
// Helper function to get tags from either tags array or tagNames array // Helper function to get tags from either tags array or tagNames array
const getTags = () => { const getTags = () => {
if (Array.isArray(story.tags) && story.tags.length > 0) { if (Array.isArray(story.tags) && story.tags.length > 0) {

View File

@@ -37,7 +37,7 @@ export default function StoryRating({
} }
}; };
const displayRating = hoveredRating || rating; const displayRating = hoveredRating || (rating || 0);
return ( return (
<div className="flex items-center gap-1"> <div className="flex items-center gap-1">

69
migrate-volumes.sh Normal file
View File

@@ -0,0 +1,69 @@
#!/bin/bash
# Migration script: move StoryCove Docker volume data to new NAS directories.
# Run this on the NAS as root (or with sudo) BEFORE restarting the stack.
set -euo pipefail
SRC_BASE="/volume1/@docker/volumes"
DST_BASE="/volume1/docker/storycove"
declare -A VOLUMES=(
["storycove_solr_data/_data"]="solr"
["storycove_postgres_data/_data"]="postgres"
["storycove_library_config/_data"]="config"
["storycove_images_data/_data"]="images"
["storycove_automatic_backups/_data"]="backups"
)
echo "=== StoryCove volume migration ==="
echo ""
# Verify source directories exist
for src_rel in "${!VOLUMES[@]}"; do
src="$SRC_BASE/$src_rel"
if [ ! -d "$src" ]; then
echo "ERROR: Source directory not found: $src"
exit 1
fi
done
# Create destination directories if they don't exist
for dst_rel in "${VOLUMES[@]}"; do
dst="$DST_BASE/$dst_rel"
if [ ! -d "$dst" ]; then
echo "Creating directory: $dst"
mkdir -p "$dst"
fi
done
echo ""
echo "Stopping StoryCove stack (docker compose down)..."
cd "$(dirname "$0")"
docker compose down
echo ""
echo "Migrating data..."
for src_rel in "${!VOLUMES[@]}"; do
dst_rel="${VOLUMES[$src_rel]}"
src="$SRC_BASE/$src_rel"
dst="$DST_BASE/$dst_rel"
echo ""
echo " $src"
echo " -> $dst"
rsync -a --info=progress2 "$src/" "$dst/"
done
echo ""
echo "Migration complete."
echo ""
echo "Old volume directories have NOT been deleted."
echo "Once you have verified the stack works correctly, you can remove them with:"
echo ""
for src_rel in "${!VOLUMES[@]}"; do
echo " rm -rf \"$SRC_BASE/$src_rel\""
done
echo ""
echo "Start the stack again with: docker compose up -d"