Files
AutonetSellCar/backend/regenerate_pdf.py
AutonetSellCar Deploy 1f0dcb1ddb Initial commit: AutonetSellCar platform with deployment system
- Frontend: Next.js 14 with TypeScript
- Backend: FastAPI with SQLAlchemy
- Agent: Carmodoo sync agent
- Deployment: Docker Compose based staging/production setup
- Scripts: Automated deployment with rollback support

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 13:24:39 +09:00

50 lines
1.5 KiB
Python

"""Regenerate PDF for performance checks with new settings"""
import asyncio
import sqlite3
import os
import sys
from pathlib import Path
sys.path.insert(0, r'D:\Workspace\claudeCode\AutonetSellCar.com\backend')
os.chdir(r'D:\Workspace\claudeCode\AutonetSellCar.com\backend')
from app.services.pdf_service import capture_performance_check_pdf, PDF_STORAGE_DIR
async def regenerate_pdfs():
conn = sqlite3.connect('autonet.db')
cursor = conn.cursor()
# Delete old PDFs
print("=== Deleting old PDFs ===")
for pdf_file in PDF_STORAGE_DIR.glob("*.pdf"):
print(f" Deleting: {pdf_file.name}")
pdf_file.unlink()
# Get all records with check_number
cursor.execute("""
SELECT car_id, check_number FROM car_performance_checks
WHERE check_number IS NOT NULL AND check_number != ''
""")
records = cursor.fetchall()
print(f"\n=== Regenerating PDFs for {len(records)} records ===")
for car_id, check_number in records:
print(f"\nGenerating PDF for Car ID: {car_id}, Check#: {check_number}")
pdf_path = await capture_performance_check_pdf(check_number, car_id)
if pdf_path:
print(f" SUCCESS: {pdf_path}")
# Update database
cursor.execute("UPDATE car_performance_checks SET pdf_path = ? WHERE car_id = ?", (pdf_path, car_id))
conn.commit()
else:
print(f" FAILED")
conn.close()
print("\nDone!")
if __name__ == "__main__":
asyncio.run(regenerate_pdfs())