"""Quick diagnostic script to check sample paths in both databases."""

import json
from db_utils import DatabaseConnection

# Load configuration
with open('config.json', 'r') as f:
    config = json.load(f)

# Connect to databases
print("Connecting to source database...")
source_conn = DatabaseConnection(config['source_db'])

print("Connecting to target database...")
target_conn = DatabaseConnection(config['target_db'])

# Get sample paths from source
print("\n" + "="*50)
print("SAMPLE PATHS FROM SOURCE (_Citadel_CS_Test)")
print("="*50)
source_samples = source_conn.execute_query("""
    SELECT TOP 10
        d.DocumentID,
        d.Filename,
        p.Path AS FolderPath,
        p.Path + '\\' + d.Filename AS FullVaultPath
    FROM Documents d
    INNER JOIN DocumentsInProjects dp ON d.DocumentID = dp.DocumentID
    INNER JOIN Projects p ON dp.ProjectID = p.ProjectID
    ORDER BY d.DocumentID
""")

for doc in source_samples:
    print(f"DocID: {doc['DocumentID']}")
    print(f"  Filename: {doc['Filename']}")
    print(f"  FolderPath: [{doc['FolderPath']}]")
    print(f"  FullVaultPath: [{doc['FullVaultPath']}]")
    print()

# Get sample paths from target
print("\n" + "="*50)
print("SAMPLE PATHS FROM TARGET (IDSVault_Test)")
print("="*50)
target_samples = target_conn.execute_query("""
    SELECT TOP 10
        d.DocumentID,
        d.Filename,
        p.Path AS FolderPath,
        p.Path + '\\' + d.Filename AS FullVaultPath
    FROM Documents d
    INNER JOIN DocumentsInProjects dp ON d.DocumentID = dp.DocumentID
    INNER JOIN Projects p ON dp.ProjectID = p.ProjectID
    ORDER BY d.DocumentID
""")

for doc in target_samples:
    print(f"DocID: {doc['DocumentID']}")
    print(f"  Filename: {doc['Filename']}")
    print(f"  FolderPath: [{doc['FolderPath']}]")
    print(f"  FullVaultPath: [{doc['FullVaultPath']}]")
    print()

# Close connections
source_conn.close()
target_conn.close()
