CoolFace
Apppublic

kaan1233/bistelligence-api

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes
update_cache.cpython-313.pyc47 linesDownload Raw Back to __pycache__
1�

2`�?j��4�SSKrSSKr\"SSSS9r\R	5rSSS5 Sr\RS\5rSr\RS	\S3-5r\"SSSS9r\R\5 SSS5 g!,(df   N\=f!,(df   g=f)�Nz	server.py�rzutf-8)�encodingu3    global market_regime, stock_data, recommendations, elite_ai_report4    cache_file = "ai_cache.json"5    import time6    7    # Cache Kontrolü (6 saatten yeniyse kullan)8    if os.path.exists(cache_file):9        file_age = time.time() - os.path.getmtime(cache_file)10        if file_age < 6 * 3600:11            print("[ÖNBELLEK] Son 6 saat içinde analiz yapılmış. Cache yükleniyor...")12            try:13                with open(cache_file, "r", encoding="utf-8") as f:14                    cache_data = json.load(f)15                market_regime = cache_data.get("market_regime", {})16                stock_data = cache_data.get("stock_data", {})17                recommendations = cache_data.get("recommendations", [])18                elite_ai_report = cache_data.get("elite_ai_report", "Önbellekten yüklendi.")19                print(f"  {len(recommendations)} hisse sonucu önbellekten alındı. (API KOTASI KORUNDU)")20                return21            except Exception as e:22                print(f"[UYARI] Önbellek okunamadı: {e}. Yeniden analiz edilecek.")23z6    global market_regime, stock_data, recommendations24u25    print(f"{'=' * 60}")26 27    # Önbelleğe Kaydet28    try:29        cache_data = {30            "market_regime": market_regime,31            "stock_data": stock_data,32            "recommendations": recommendations,33            "elite_ai_report": elite_ai_report34        }35        with open("ai_cache.json", "w", encoding="utf-8") as f:36            json.dump(cache_data, f, ensure_ascii=False)37        print("  Sonuçlar başarıyla ai_cache.json dosyasına kaydedildi.")38    except Exception as e:39        print(f"  Cache kaydedilemedi: {e}")40z2    print(f"{'=' * 60}")41 42@app.on_event("startup")z43@app.on_event("startup")�w)44�json�re�open�f�read�content�cache_logic�replace�save_cache_logic�write���update_cache.py�<module>rs����	�	�+�s�W�-���f�f�h�G�.���,�/�/�S�U`�45a����$�/�/�T�Vf�jH�WH�I��	�+�s�W�-���G�G�G��.�-�_.�-��^.�-�s�A8�B	�846B�	47B