""" Count how many domains have each template assigned Usage: uv run python scripts/count_templates_by_domain.py """ import sys from pathlib import Path from collections import Counter project_root = Path(__file__).parent.parent sys.path.insert(0, str(project_root)) from src.database.session import db_manager from src.database.models import SiteDeployment def count_templates(): """Count templates across all site deployments""" db_manager.initialize() session = db_manager.get_session() try: sites = session.query(SiteDeployment.template_name).all() template_counts = Counter() for (template_name,) in sites: template_counts[template_name] += 1 print(f"\nTotal sites: {sum(template_counts.values())}") print("\nTemplate distribution:") print("-" * 40) for template, count in sorted(template_counts.items()): print(f" {template:20} : {count:4}") print("-" * 40) finally: session.close() if __name__ == "__main__": count_templates()