seawolf2357 commited on
Commit
c191368
·
verified ·
1 Parent(s): 53206c4

Update fund.py

Browse files
Files changed (1) hide show
  1. fund.py +23 -11
fund.py CHANGED
@@ -38,13 +38,23 @@ import math
38
  # ============================================================================
39
  # cache_db 연동 (app.py 통합 시 DB 저장/불러오기)
40
  # ============================================================================
41
- try:
42
- from cache_db import get_fund_cache
43
- _fund_cache = get_fund_cache()
44
- HAS_CACHE_DB = True
45
- except ImportError:
46
- HAS_CACHE_DB = False
47
- _fund_cache = None
 
 
 
 
 
 
 
 
 
 
48
 
49
  # ============================================================================
50
  # CUSTOM CSS - 울트라 다크 메탈릭 + 네온 글로우 테마
@@ -1465,7 +1475,8 @@ def save_fund_results(email, company_name, biz_num, industry, sales, years, cred
1465
  op_profit, net_income, interest_exp, caution_checks,
1466
  existing_guar, related_sales):
1467
  """분석 결과 저장"""
1468
- if not HAS_CACHE_DB:
 
1469
  return "⚠️ cache_db 모듈을 찾을 수 없습니다. app.py 통합 환경에서 실행해주세요."
1470
 
1471
  if not email or '@' not in email:
@@ -1491,19 +1502,20 @@ def save_fund_results(email, company_name, biz_num, industry, sales, years, cred
1491
  "version": "v7.0"
1492
  }
1493
 
1494
- success, msg = _fund_cache.save_fund_analysis(email, company_info, financial_info, caution_checks, analysis_results)
1495
  return msg
1496
 
1497
 
1498
  def load_fund_results(email):
1499
  """저장된 분석 기록 불러오기 → 입력 필드에 복원"""
1500
- if not HAS_CACHE_DB:
 
1501
  return [gr.update()] * 22 + ["⚠️ cache_db 모듈을 찾을 수 없습니다. app.py 통합 환경에서 실행해주세요."]
1502
 
1503
  if not email or '@' not in email:
1504
  return [gr.update()] * 22 + ["⚠️ 올바른 이메일 주소를 입력해주세요."]
1505
 
1506
- record, msg = _fund_cache.load_fund_profile(email)
1507
 
1508
  if record is None:
1509
  return [gr.update()] * 22 + [msg]
 
38
  # ============================================================================
39
  # cache_db 연동 (app.py 통합 시 DB 저장/불러오기)
40
  # ============================================================================
41
+ HAS_CACHE_DB = False
42
+ _fund_cache = None
43
+
44
+ def _get_fund_cache():
45
+ """지연 초기화 - 실제 사용 시점에 cache_db 로드"""
46
+ global HAS_CACHE_DB, _fund_cache
47
+ if _fund_cache is not None:
48
+ return _fund_cache
49
+ try:
50
+ from cache_db import get_fund_cache
51
+ _fund_cache = get_fund_cache()
52
+ HAS_CACHE_DB = True
53
+ return _fund_cache
54
+ except ImportError:
55
+ HAS_CACHE_DB = False
56
+ _fund_cache = None
57
+ return None
58
 
59
  # ============================================================================
60
  # CUSTOM CSS - 울트라 다크 메탈릭 + 네온 글로우 테마
 
1475
  op_profit, net_income, interest_exp, caution_checks,
1476
  existing_guar, related_sales):
1477
  """분석 결과 저장"""
1478
+ cache = _get_fund_cache()
1479
+ if cache is None:
1480
  return "⚠️ cache_db 모듈을 찾을 수 없습니다. app.py 통합 환경에서 실행해주세요."
1481
 
1482
  if not email or '@' not in email:
 
1502
  "version": "v7.0"
1503
  }
1504
 
1505
+ success, msg = cache.save_fund_analysis(email, company_info, financial_info, caution_checks, analysis_results)
1506
  return msg
1507
 
1508
 
1509
  def load_fund_results(email):
1510
  """저장된 분석 기록 불러오기 → 입력 필드에 복원"""
1511
+ cache = _get_fund_cache()
1512
+ if cache is None:
1513
  return [gr.update()] * 22 + ["⚠️ cache_db 모듈을 찾을 수 없습니다. app.py 통합 환경에서 실행해주세요."]
1514
 
1515
  if not email or '@' not in email:
1516
  return [gr.update()] * 22 + ["⚠️ 올바른 이메일 주소를 입력해주세요."]
1517
 
1518
+ record, msg = cache.load_fund_profile(email)
1519
 
1520
  if record is None:
1521
  return [gr.update()] * 22 + [msg]