""" 2월 데이터 최종 검증 """ import sys import os from datetime import datetime from dotenv import load_dotenv load_dotenv() if sys.platform.startswith('win'): sys.stdout.reconfigure(encoding='utf-8') sys.stderr.reconfigure(encoding='utf-8') current_dir = os.path.dirname(os.path.abspath(__file__)) sys.path.append(current_dir) from database import get_supabase_client def final_check(): client = get_supabase_client() if not client: print("❌ Supabase 연결 실패") return print("\n" + "="*70) print("📊 2월 데이터 최종 검증 결과") print("="*70) plants = [ ('kremc-05', '5호기'), ('nrems-09', '9호기') ] for plant_id, plant_name in plants: print(f"\n🏭 [{plant_name}] ({plant_id})") print("-" * 70) # 시간별 데이터 hourly = client.table("solar_logs") \ .select("*", count='exact') \ .eq("plant_id", plant_id) \ .gte("created_at", "2026-02-01T00:00:00+09:00") \ .lte("created_at", "2026-02-27T23:59:59+09:00") \ .execute() hourly_count = hourly.count if hasattr(hourly, 'count') else len(hourly.data) # 일별 데이터 daily = client.table("daily_stats") \ .select("*", count='exact') \ .eq("plant_id", plant_id) \ .gte("date", "2026-02-01") \ .lte("date", "2026-02-27") \ .execute() daily_count = daily.count if hasattr(daily, 'count') else len(daily.data) total_gen = sum(r.get('total_generation', 0) for r in daily.data) avg_gen = total_gen / daily_count if daily_count > 0 else 0 # 월별 통계 monthly = client.table("monthly_stats") \ .select("*") \ .eq("plant_id", plant_id) \ .eq("month", "2026-02") \ .execute() monthly_gen = monthly.data[0].get('total_generation', 0) if monthly.data else 0 print(f" ✅ 시간별 데이터 (Hourly): {hourly_count}건") print(f" ✅ 일별 데이터 (Daily): {daily_count}건") print(f" 📈 2월 총 발전량: {total_gen:,.2f} kWh") print(f" 📈 일평균 발전량: {avg_gen:,.2f} kWh/day") print(f" 📊 월별 통계: {monthly_gen:,.2f} kWh") print("\n" + "="*70) print("✅ 모든 데이터가 Supabase DB에 정상 저장되었습니다!") print("="*70 + "\n") if __name__ == "__main__": final_check()