# Quick Fix Guide - PPTX Files Showing 0 Usage

## Problem Summary
Your PPTX file `20251016-153526-9c6b119b0ea8b3b0fca205fb5e80cfbb.pptx` shows 0 usage even though it's being used in an event attachment.

## Why This Happened
The file tracking system wasn't tracking event attachments - only the main image_url and file_url fields. The attachments array was being ignored.

## Immediate Solution

### Step 1: Rebuild & Restart Backend
```powershell
# In your project root directory
cd c:\Users\conta\Downloads\PROG+HTML\Fotbal\fotbal-club

# Rebuild the Go backend
go build -o bin/fotbal-club.exe

# Restart the backend server
# Stop the current server (Ctrl+C if running)
# Then start it again
.\bin\fotbal-club.exe
```

### Step 2: Rebuild Frontend (if needed)
```powershell
cd frontend
npm run build
```

### Step 3: Use the New Refresh Button
1. Log in to your admin panel
2. Go to **Správa souborů** (Files Management)
3. Click the green **"Aktualizovat sledování"** button
4. Wait for completion - you'll see a modal with statistics
5. Close the modal and check your files list
6. The PPTX file should now show usage count > 0

## What Was Fixed

### Backend Fixes
1. **Event attachment tracking** - Now properly scans all attachments in events
2. **Article attachment tracking** - Fixed bug where only one attachment was tracked
3. **New admin endpoint** - `/api/v1/admin/files/refresh-tracking` to re-scan everything
4. **Better MIME detection** - Added PPTX, DOCX, XLSX, and many other file types

### Frontend Fixes
1. **New refresh button** - Green "Aktualizovat sledování" button
2. **Result modal** - Shows statistics after refresh
3. **Better UX** - Two separate buttons: Scan files vs Refresh tracking

## Verification

After running the refresh, verify the fix:
1. Go to Files Management
2. Search for your PPTX file: `20251016-153526-9c6b119b0ea8b3b0fca205fb5e80cfbb.pptx`
3. Check the "Použití" (Usage) column - should now show 1 or more
4. Click on the usage count to see where it's being used
5. Should show the event details

## Future Prevention
The fix is now permanent. All new events/articles with attachments will be automatically tracked correctly. You only need to use the "Refresh" button if:
- You have old data from before this fix
- You manually edit the database
- You suspect tracking data is out of sync

## Troubleshooting

### If the usage still shows 0:
1. Check if the event still exists and has the attachment
2. Verify the attachment URL matches the file URL exactly
3. Check server logs for any errors during refresh
4. Try refreshing just events: Add `?entity_type=event` to the API call

### If you get errors:
1. Check that the backend compiled successfully (no Go errors)
2. Verify the database migrations ran (the file_usages table exists)
3. Check that you're logged in as admin
4. Look at browser console for API errors

## Technical Details
See `FILE_TRACKING_ENHANCEMENT.md` for complete technical documentation.
