from config.loader import CONFIG
from database.repository import fetch_recent_snapshots
from analytics.engine import calculate_top_velocity_regression

if __name__ == "__main__":
    top_k_val = CONFIG["analytics"].get("default_top_k", 10)

    print("=== LATEST 10 DATABASE ENTRIES ===")
    recent_df = fetch_recent_snapshots(limit=10)
    if recent_df.empty:
        print("No entries found yet. Run main.py first.")
    else:
        print(recent_df.to_string(index=False))

    print(f"\n=== VELOCITY LEADERBOARD (PREVIEW: min_days=0.0, top_{top_k_val}) ===")
    leaderboard = calculate_top_velocity_regression(min_days=0.0, top_k=top_k_val)
    if leaderboard.empty:
        print("Need at least 3 unique snapshot cycles to compute linear regressions.")
    else:
        print(leaderboard.to_string(index=False))