|
|
@@ -25,20 +25,6 @@ class HotRecallModel:
|
|
|
for item, _ in info:
|
|
|
hotkeys.append(item)
|
|
|
return hotkeys
|
|
|
-
|
|
|
-
|
|
|
- # def _load_data_from_dataset(self):
|
|
|
- # """从数据库中读取数据"""
|
|
|
- # client = Mysql()
|
|
|
- # tablename = "mock_order"
|
|
|
- # query_text = "*"
|
|
|
-
|
|
|
- # df = client.load_data(tablename, query_text)
|
|
|
-
|
|
|
- # # 去除重复值和填补缺失值
|
|
|
- # df.drop_duplicates(inplace=True)
|
|
|
- # df.fillna(0, inplace=True)
|
|
|
- # return df
|
|
|
|
|
|
def _calculate_hot_score(self, hot_name):
|
|
|
"""
|
|
|
@@ -70,10 +56,12 @@ class HotRecallModel:
|
|
|
def to_redis(self, rec_content_score, city_uuid):
|
|
|
hotkey_name = rec_content_score["key"]
|
|
|
rec_item_id = f"hot:{city_uuid}:{str(hotkey_name)}" # 修正 rec_item_id 拼接方式
|
|
|
- # rec_item_id = "hot:" + city_uuid + ":" + str(hotkey_name)
|
|
|
+
|
|
|
+ # 清空 sorted set 数据,确保不会影响后续的存储
|
|
|
+ self._redis_db.redis.delete(rec_item_id)
|
|
|
+
|
|
|
res = {}
|
|
|
|
|
|
- # rec_content_score["value"] 是一个包含字典的列表
|
|
|
for item in rec_content_score["value"]:
|
|
|
for content, score in item.items(): # item 形如 {A001: 75.0}
|
|
|
res[content] = float(score) # 确保 score 是 float 类型
|