//! Verify Test Data - Check what's actually in your test data

use anyhow::Result;
use rag_module::*;
use std::collections::HashMap;

#[tokio::main]
async fn main() -> Result<()> {
    println!("🔍 VERIFYING TEST DATA CONTENTS");
    println!("===============================\n");
    
    let rag = create_rag_module("./test_data").await?;
    rag.initialize().await?;
    
    let user_id = "test_user_123";
    let docs = rag.get_collection_documents("aws_estate", user_id).await?;
    
    println!("📊 TOTAL DOCUMENTS: {}\n", docs.len());
    
    // Count by service type by examining the decrypted content
    let mut service_counts: HashMap<String, Vec<String>> = HashMap::new();
    
    for (i, doc) in docs.iter().enumerate() {
        // Try to identify service from document ID or content
        let service = if doc.id.contains("ec2") {
            "ec2"
        } else if doc.id.contains("rds") {
            "rds"
        } else if doc.id.contains("s3") {
            "s3" 
        } else if doc.id.contains("lambda") {
            "lambda"
        } else if doc.id.contains("iam") {
            "iam"
        } else if doc.id.contains("vpc") {
            "vpc"
        } else {
            "unknown"
        };
        
        service_counts.entry(service.to_string())
            .or_insert_with(Vec::new)
            .push(format!("{}. {}", i+1, doc.id));
    }
    
    println!("📋 BREAKDOWN BY SERVICE:");
    for (service, documents) in &service_counts {
        println!("\n🔹 {} ({} documents):", service.to_uppercase(), documents.len());
        for doc_info in documents {
            println!("   {}", doc_info);
        }
    }
    
    println!("\n📊 SUMMARY:");
    for (service, documents) in &service_counts {
        println!("• {}: {} documents", service.to_uppercase(), documents.len());
    }
    
    // Expected vs Actual
    println!("\n🎯 EXPECTED vs ACTUAL:");
    println!("• EC2: Expected 4, Actual {}", service_counts.get("ec2").map(|v| v.len()).unwrap_or(0));
    println!("• RDS: Expected 2, Actual {}", service_counts.get("rds").map(|v| v.len()).unwrap_or(0));
    println!("• S3: Expected 5, Actual {}", service_counts.get("s3").map(|v| v.len()).unwrap_or(0));
    println!("• Lambda: Expected 3, Actual {}", service_counts.get("lambda").map(|v| v.len()).unwrap_or(0));
    println!("• IAM: Expected 3, Actual {}", service_counts.get("iam").map(|v| v.len()).unwrap_or(0));
    println!("• VPC: Expected 1, Actual {}", service_counts.get("vpc").map(|v| v.len()).unwrap_or(0));
    
    Ok(())
}