Project-Image-Uploader/tests/test-cleanup.sh
matthias.lotz 4ee1b76d77 docs: Finalize automatic cleanup feature documentation
- Update README.md with comprehensive feature description
  - Add automatic cleanup and deletion log to features list
  - Document countdown display and 7-day retention policy
  - Add Testing section with test-cleanup.sh instructions
  - Update API endpoints with new admin routes

- Update CHANGELOG.md with complete feature overview
  - Backend: Services, Repositories, Scheduler, API endpoints
  - Frontend: DeletionLogSection, countdown, SweetAlert2 feedback
  - Infrastructure: nginx config updates
  - Testing: Comprehensive test tools and documentation

- Update TODO.md marking feature as completed

- Update FEATURE_PLAN with final status
  - All 11 tasks completed (100%)
  - Bug fixes documented
  - Deployment checklist updated
  - Final timeline and statistics

- Organize test files into tests/ directory
  - Move TESTING-CLEANUP.md to tests/
  - Move test-cleanup.sh to tests/

Feature is now complete and ready for merge.
2025-11-08 14:45:13 +01:00

100 lines
3.3 KiB
Bash
Executable File

#!/bin/bash
# Cleanup Test Helper Script
# Hilft beim Testen des automatischen Löschens
echo "========================================"
echo " CLEANUP TEST HELPER"
echo "========================================"
echo ""
# Prüfe ob Container läuft
if ! docker compose -f docker/dev/docker-compose.yml ps | grep -q "backend-dev.*Up"; then
echo "❌ Backend-Container läuft nicht. Bitte starte ./dev.sh"
exit 1
fi
function show_unapproved_groups() {
echo "📋 Nicht-freigegebene Gruppen:"
echo ""
docker compose -f docker/dev/docker-compose.yml exec -T backend-dev sqlite3 /usr/src/app/src/data/db/image_uploader.db \
"SELECT group_id || ' | Jahr: ' || year || ' | Name: ' || name || ' | Upload: ' || datetime(upload_date) || ' | Tage: ' || CAST((julianday('now') - julianday(upload_date)) AS INTEGER)
FROM groups WHERE approved = 0 ORDER BY upload_date DESC;"
echo ""
}
function backdate_group() {
show_unapproved_groups
echo ""
read -p "Gruppe ID zum Zurückdatieren: " group_id
read -p "Um wie viele Tage? (z.B. 8): " days
docker compose -f docker/dev/docker-compose.yml exec -T backend-dev sqlite3 /usr/src/app/src/data/db/image_uploader.db \
"UPDATE groups SET upload_date = datetime('now', '-$days days') WHERE group_id = '$group_id';"
echo "✅ Gruppe $group_id wurde um $days Tage zurückdatiert"
echo ""
# Zeige aktualisierte Info
docker compose -f docker/dev/docker-compose.yml exec -T backend-dev sqlite3 /usr/src/app/src/data/db/image_uploader.db \
"SELECT 'Gruppe: ' || group_id || ', Upload: ' || datetime(upload_date) || ', Tage alt: ' || CAST((julianday('now') - julianday(upload_date)) AS INTEGER)
FROM groups WHERE group_id = '$group_id';"
echo ""
}
function preview_cleanup() {
echo "🔍 Cleanup Preview (über API):"
echo ""
curl -s http://localhost:5001/api/admin/cleanup/preview | jq '.'
echo ""
}
function trigger_cleanup() {
echo "⚠️ ACHTUNG: Dies wird Gruppen permanent löschen!"
echo ""
read -p "Cleanup wirklich ausführen? (ja/nein): " confirm
if [ "$confirm" != "ja" ]; then
echo "❌ Abgebrochen"
return
fi
echo ""
echo "🔄 Führe Cleanup aus..."
echo ""
curl -s -X POST http://localhost:5001/api/admin/cleanup/trigger | jq '.'
echo ""
}
function show_deletion_log() {
echo "📜 Lösch-Historie (letzte 10):"
echo ""
curl -s http://localhost:5001/api/admin/deletion-log?limit=10 | jq '.deletions[] | "Gruppe: \(.group_id), Jahr: \(.year), Bilder: \(.image_count), Gelöscht: \(.deleted_at)"'
echo ""
}
# Menü
while true; do
echo "Optionen:"
echo " 1) Zeige nicht-freigegebene Gruppen"
echo " 2) Gruppe zurückdatieren (für Tests)"
echo " 3) Preview: Was würde gelöscht?"
echo " 4) Cleanup JETZT ausführen"
echo " 5) Lösch-Historie anzeigen"
echo " 0) Beenden"
echo ""
read -p "Wähle Option: " option
echo ""
case $option in
1) show_unapproved_groups ;;
2) backdate_group ;;
3) preview_cleanup ;;
4) trigger_cleanup ;;
5) show_deletion_log ;;
0) echo "👋 Auf Wiedersehen!"; exit 0 ;;
*) echo "❌ Ungültige Option" ;;
esac
done