67 lines
2.0 KiB
Python
67 lines
2.0 KiB
Python
"""
|
|
List all Tier 1 articles for a project with their URLs, templates, and hero URLs
|
|
|
|
Usage:
|
|
uv run python scripts/list_t1_articles.py [project_id]
|
|
|
|
If project_id is not provided, defaults to project 30.
|
|
"""
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
project_root = Path(__file__).parent.parent
|
|
sys.path.insert(0, str(project_root))
|
|
|
|
from src.database.session import db_manager
|
|
from src.database.repositories import GeneratedContentRepository, ProjectRepository
|
|
|
|
|
|
def list_t1_articles(project_id: int = 30):
|
|
"""List all Tier 1 articles for a project"""
|
|
session = db_manager.get_session()
|
|
try:
|
|
content_repo = GeneratedContentRepository(session)
|
|
project_repo = ProjectRepository(session)
|
|
|
|
project = project_repo.get_by_id(project_id)
|
|
if not project:
|
|
print(f"Project {project_id} not found")
|
|
return
|
|
|
|
articles = content_repo.get_by_project_and_tier(project_id, "tier1", require_site=False)
|
|
|
|
if not articles:
|
|
print(f"No Tier 1 articles found for project {project_id}")
|
|
return
|
|
|
|
print(f"\nProject {project_id}: {project.name}")
|
|
print("=" * 140)
|
|
print(f"{'Article URL':<60} {'Template':<20} {'Hero URL':<60}")
|
|
print("=" * 140)
|
|
|
|
for article in articles:
|
|
article_url = article.deployed_url or "(Not deployed)"
|
|
template = article.template_used or "(No template)"
|
|
hero_url = article.hero_image_url or "(No hero image)"
|
|
|
|
print(f"{article_url:<60} {template:<20} {hero_url:<60}")
|
|
|
|
print("=" * 140)
|
|
print(f"\nTotal Tier 1 articles: {len(articles)}")
|
|
|
|
finally:
|
|
session.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
project_id = 30
|
|
if len(sys.argv) > 1:
|
|
try:
|
|
project_id = int(sys.argv[1])
|
|
except ValueError:
|
|
print(f"Invalid project_id: {sys.argv[1]}. Using default: 30")
|
|
|
|
list_t1_articles(project_id)
|
|
|