release
This commit is contained in:
@@ -892,8 +892,14 @@ class VectorService:
|
||||
|
||||
return recommendations
|
||||
|
||||
def get_db_status(self) -> Dict[str, Any]:
|
||||
"""DB 상태 정보 반환"""
|
||||
def get_db_status(self, include_store_ids: bool = True, store_limit: int = 200) -> Dict[str, Any]:
|
||||
"""
|
||||
DB 상태 정보 반환 - store_id 목록 포함
|
||||
|
||||
Args:
|
||||
include_store_ids: store_id 목록 포함 여부
|
||||
store_limit: store_id 목록 최대 개수
|
||||
"""
|
||||
try:
|
||||
if not self.is_ready():
|
||||
return {
|
||||
@@ -902,19 +908,27 @@ class VectorService:
|
||||
'total_stores': 0,
|
||||
'db_path': self.db_path,
|
||||
'status': 'not_ready',
|
||||
'error': self.initialization_error
|
||||
'error': self.initialization_error,
|
||||
'store_ids': []
|
||||
}
|
||||
|
||||
# 컬렉션 정보 조회
|
||||
# 기본 컬렉션 정보 조회
|
||||
count = self.collection.count()
|
||||
|
||||
# store_id 목록 조회 (옵션)
|
||||
store_ids = []
|
||||
if include_store_ids:
|
||||
store_ids = self.get_all_store_ids(limit=store_limit)
|
||||
|
||||
return {
|
||||
'collection_name': self.collection_name,
|
||||
'total_documents': count,
|
||||
'total_stores': count, # 각 문서가 하나의 가게를 나타냄
|
||||
'total_stores': len(store_ids) if include_store_ids else count,
|
||||
'db_path': self.db_path,
|
||||
'status': 'ready',
|
||||
'last_updated': datetime.now().isoformat()
|
||||
'last_updated': datetime.now().isoformat(),
|
||||
# 새로 추가되는 정보
|
||||
'store_ids': store_ids
|
||||
}
|
||||
|
||||
except Exception as e:
|
||||
@@ -925,7 +939,8 @@ class VectorService:
|
||||
'total_stores': 0,
|
||||
'db_path': self.db_path,
|
||||
'status': 'error',
|
||||
'error': str(e)
|
||||
'error': str(e),
|
||||
'store_ids': []
|
||||
}
|
||||
|
||||
def get_existing_store_data(self, region: str = None, food_category: str = None) -> Dict[str, Dict[str, Any]]:
|
||||
@@ -1238,4 +1253,54 @@ class VectorService:
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"❌ 매장 정보 조회 실패: store_id={store_id}, error={e}")
|
||||
return None
|
||||
return None
|
||||
|
||||
def get_all_store_ids(self, limit: int = 200) -> List[str]:
|
||||
"""
|
||||
Vector DB에 저장된 모든 store_id 목록을 조회합니다.
|
||||
|
||||
Args:
|
||||
limit: 반환할 최대 store_id 수 (기본값: 200)
|
||||
|
||||
Returns:
|
||||
store_id 문자열 리스트
|
||||
"""
|
||||
try:
|
||||
if not self.is_ready():
|
||||
logger.warning("⚠️ VectorService가 준비되지 않음")
|
||||
return []
|
||||
|
||||
logger.info(f"🏪 전체 store_id 목록 조회 시작 (최대 {limit}개)")
|
||||
|
||||
# Vector DB에서 모든 메타데이터 조회
|
||||
results = self.collection.get(
|
||||
include=['metadatas'],
|
||||
limit=limit # 성능을 위한 제한
|
||||
)
|
||||
|
||||
if not results or not results.get('metadatas'):
|
||||
logger.info("📊 Vector DB에 저장된 매장이 없습니다")
|
||||
return []
|
||||
|
||||
# store_id만 추출 및 중복 제거
|
||||
store_ids = []
|
||||
seen_ids = set()
|
||||
|
||||
for metadata in results['metadatas']:
|
||||
if not metadata:
|
||||
continue
|
||||
|
||||
store_id = metadata.get('store_id', '')
|
||||
if store_id and store_id not in seen_ids:
|
||||
store_ids.append(store_id)
|
||||
seen_ids.add(store_id)
|
||||
|
||||
# store_id로 정렬 (숫자 순서)
|
||||
store_ids.sort()
|
||||
|
||||
logger.info(f"✅ store_id 목록 조회 완료: {len(store_ids)}개")
|
||||
return store_ids
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"❌ store_id 목록 조회 실패: {e}")
|
||||
return []
|
||||
Reference in New Issue
Block a user