-
- PunimTag
-
+
+

{
+ // Fallback if logo.png doesn't exist, try logo.svg
+ const target = e.target as HTMLImageElement
+ if (target.src.endsWith('logo.png')) {
+ target.src = '/logo.svg'
+ }
+ }}
+ />
+
Photo Management System
diff --git a/frontend/src/pages/PendingPhotos.tsx b/frontend/src/pages/PendingPhotos.tsx
index c32175f..668ab3d 100644
--- a/frontend/src/pages/PendingPhotos.tsx
+++ b/frontend/src/pages/PendingPhotos.tsx
@@ -379,7 +379,7 @@ export default function PendingPhotos() {
const handleCleanupDatabase = async (statusFilter?: string) => {
const confirmMessage = statusFilter
? `Delete all ${statusFilter} records from pending_photos table? This cannot be undone.`
- : 'Delete ALL records from pending_photos table? This cannot be undone.'
+ : 'Delete all approved and rejected records from pending_photos table? Pending records will be kept. This cannot be undone.'
if (!confirm(confirmMessage)) {
return
@@ -523,7 +523,7 @@ export default function PendingPhotos() {
className="px-3 py-1.5 text-sm bg-gray-200 text-gray-700 rounded-md hover:bg-gray-300 font-medium"
title={
canRunCleanup
- ? 'Delete all records from pending_photos table'
+ ? 'Delete approved and rejected records from pending_photos table (pending records will be kept)'
: 'Clear database is restricted to admins'
}
>
diff --git a/src/web/api/pending_photos.py b/src/web/api/pending_photos.py
index f4569f7..aad73f7 100644
--- a/src/web/api/pending_photos.py
+++ b/src/web/api/pending_photos.py
@@ -531,13 +531,13 @@ def cleanup_shared_files(
@router.post("/cleanup-database", response_model=CleanupResponse)
def cleanup_pending_photos_database(
current_admin: dict = Depends(get_current_admin_user),
- status_filter: Optional[str] = Query(None, description="Filter by status: 'approved', 'rejected', or None for all"),
+ status_filter: Optional[str] = Query(None, description="Filter by status: 'approved', 'rejected', or None for approved+rejected (excludes pending)"),
auth_db: Session = Depends(get_auth_db),
) -> CleanupResponse:
"""Delete records from pending_photos table.
Args:
- status_filter: Optional filter - 'approved', 'rejected', or None for all records
+ status_filter: Optional filter - 'approved', 'rejected', or None for approved+rejected (excludes pending)
"""
deleted_records = 0
errors = []
@@ -545,9 +545,18 @@ def cleanup_pending_photos_database(
try:
# First check if table exists and has records
- check_result = auth_db.execute(text("""
- SELECT COUNT(*) as count FROM pending_photos
- """))
+ if status_filter:
+ # Check count for specific status
+ check_result = auth_db.execute(text("""
+ SELECT COUNT(*) as count FROM pending_photos
+ WHERE status = :status_filter
+ """), {"status_filter": status_filter})
+ else:
+ # Check count for approved and rejected (exclude pending)
+ check_result = auth_db.execute(text("""
+ SELECT COUNT(*) as count FROM pending_photos
+ WHERE status IN ('approved', 'rejected')
+ """))
total_count = check_result.fetchone().count if check_result else 0
if total_count == 0:
@@ -566,8 +575,10 @@ def cleanup_pending_photos_database(
WHERE status = :status_filter
"""), {"status_filter": status_filter})
else:
+ # Default behavior: delete only approved and rejected, exclude pending
result = auth_db.execute(text("""
DELETE FROM pending_photos
+ WHERE status IN ('approved', 'rejected')
"""))
deleted_records = result.rowcount if hasattr(result, 'rowcount') else 0