""" Script to check image theme prompts in the database """ import sys from pathlib import Path sys.path.insert(0, str(Path(__file__).parent.parent)) from src.database.session import db_manager from src.database.repositories import ProjectRepository def check_theme_prompts(): """Check all projects and their image theme prompts""" db_manager.initialize() session = db_manager.get_session() try: project_repo = ProjectRepository(session) projects = project_repo.get_all() print("=" * 80) print("IMAGE THEME PROMPTS IN DATABASE") print("=" * 80) print() projects_with_themes = [] projects_without_themes = [] for project in projects: if project.image_theme_prompt: projects_with_themes.append(project) else: projects_without_themes.append(project) print(f"Total projects: {len(projects)}") print(f"Projects WITH theme prompts: {len(projects_with_themes)}") print(f"Projects WITHOUT theme prompts: {len(projects_without_themes)}") print() if projects_with_themes: print("=" * 80) print("PROJECTS WITH THEME PROMPTS:") print("=" * 80) print() for project in projects_with_themes: print(f"Project ID: {project.id}") print(f"Name: {project.name}") print(f"Main Keyword: {project.main_keyword}") print(f"Theme Prompt:") print(f" {project.image_theme_prompt}") print() print("-" * 80) print() if projects_without_themes: print("=" * 80) print("PROJECTS WITHOUT THEME PROMPTS:") print("=" * 80) print() for project in projects_without_themes: print(f" ID {project.id}: {project.name} ({project.main_keyword})") print() # Check for common patterns if projects_with_themes: print("=" * 80) print("ANALYSIS:") print("=" * 80) print() blue_mentions = [] for project in projects_with_themes: theme_lower = project.image_theme_prompt.lower() if 'blue' in theme_lower: blue_mentions.append((project.id, project.name, project.image_theme_prompt)) print(f"Projects mentioning 'blue': {len(blue_mentions)}/{len(projects_with_themes)}") if blue_mentions: print() print("Projects with 'blue' in theme:") for proj_id, name, theme in blue_mentions: print(f" ID {proj_id}: {name}") print(f" Theme: {theme}") print() # Check for other common color mentions colors = ['red', 'green', 'yellow', 'orange', 'purple', 'gray', 'grey', 'black', 'white'] color_counts = {} for color in colors: count = sum(1 for p in projects_with_themes if color in p.image_theme_prompt.lower()) if count > 0: color_counts[color] = count if color_counts: print("Other color mentions:") for color, count in sorted(color_counts.items(), key=lambda x: x[1], reverse=True): print(f" {color}: {count} projects") print() finally: session.close() db_manager.close() if __name__ == "__main__": check_theme_prompts()