Spaces:
Running
on
Zero
Running
on
Zero
Update history_manager.py
Browse files- history_manager.py +0 -40
history_manager.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
|
| 2 |
from datetime import datetime
|
| 3 |
import json
|
| 4 |
import os
|
|
@@ -28,46 +27,7 @@ class UserHistoryManager:
|
|
| 28 |
except Exception as e:
|
| 29 |
print(f"Error in _init_file: {str(e)}")
|
| 30 |
print(traceback.format_exc())
|
| 31 |
-
|
| 32 |
-
# def save_history(self, user_preferences: dict = None, results: list = None, search_type: str = "criteria", description: str = None) -> bool:
|
| 33 |
-
# """
|
| 34 |
-
# 儲存搜尋歷史,支援兩種類型的搜尋
|
| 35 |
-
# Args:
|
| 36 |
-
# user_preferences: dict, 使用者偏好設定 (用於 criteria 搜尋)
|
| 37 |
-
# results: list, 推薦結果
|
| 38 |
-
# search_type: str, 搜尋類型 ("criteria" 或 "description")
|
| 39 |
-
# description: str, 使用者輸入的描述 (用於 description 搜尋)
|
| 40 |
-
# """
|
| 41 |
-
# try:
|
| 42 |
-
# taipei_tz = pytz.timezone('Asia/Taipei')
|
| 43 |
-
# taipei_time = datetime.now(taipei_tz)
|
| 44 |
-
|
| 45 |
-
# history_entry = {
|
| 46 |
-
# "timestamp": taipei_time.strftime("%Y-%m-%d %H:%M:%S"),
|
| 47 |
-
# "search_type": search_type,
|
| 48 |
-
# "results": results
|
| 49 |
-
# }
|
| 50 |
|
| 51 |
-
# # 根據搜尋類型添加不同的資訊
|
| 52 |
-
# if search_type == "criteria":
|
| 53 |
-
# history_entry["preferences"] = user_preferences
|
| 54 |
-
# else: # description
|
| 55 |
-
# history_entry["description"] = description
|
| 56 |
-
|
| 57 |
-
# with open(self.history_file, 'r', encoding='utf-8') as f:
|
| 58 |
-
# history = json.load(f)
|
| 59 |
-
|
| 60 |
-
# history.append(history_entry)
|
| 61 |
-
# if len(history) > 20:
|
| 62 |
-
# history = history[-20:]
|
| 63 |
-
|
| 64 |
-
# with open(self.history_file, 'w', encoding='utf-8') as f:
|
| 65 |
-
# json.dump(history, f, ensure_ascii=False, indent=2)
|
| 66 |
-
|
| 67 |
-
# return True
|
| 68 |
-
# except Exception as e:
|
| 69 |
-
# print(f"Error saving history: {str(e)}")
|
| 70 |
-
# return False
|
| 71 |
|
| 72 |
def save_history(self, user_preferences: dict = None, results: list = None, search_type: str = "criteria", description: str = None) -> bool:
|
| 73 |
"""
|
|
|
|
|
|
|
| 1 |
from datetime import datetime
|
| 2 |
import json
|
| 3 |
import os
|
|
|
|
| 27 |
except Exception as e:
|
| 28 |
print(f"Error in _init_file: {str(e)}")
|
| 29 |
print(traceback.format_exc())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
def save_history(self, user_preferences: dict = None, results: list = None, search_type: str = "criteria", description: str = None) -> bool:
|
| 33 |
"""
|