#!/bin/bash
# Example 11: Auto-Fix Mode

echo "============================================================"
echo "Example 11: Auto-Fix Mode"
echo "============================================================"

echo ""
echo "# Preview fixes (safe — changes nothing):"
echo "$ python manage.py fix_queries --url /api/books/"
echo ""
echo "Expected output:"
echo "--- myapp/views.py"
echo "+++ myapp/views.py (fixed)"
echo "@@ Line 15 @@"
echo "-    books = Book.objects.all()"
echo "+    books = Book.objects.select_related('author').all()"
echo ""
echo "@@ Line 28 @@"
echo "-    total = len(Book.objects.filter(active=True))"
echo "+    total = Book.objects.filter(active=True).count()"
echo ""
echo "# Apply fixes (creates .bak backups):"
echo "$ python manage.py fix_queries --url /api/books/ --apply"
echo ""
echo "# Only fix N+1 issues:"
echo "$ python manage.py fix_queries --url /api/books/ --apply --issue-type nplusone"
echo ""
echo "# Only fix specific file:"
echo "$ python manage.py fix_queries --url /api/books/ --apply --file myapp/views.py"
