Commit 7acd559c authored by 张彦钊's avatar 张彦钊

change sql for test

parent 694e9f01
......@@ -205,7 +205,8 @@ def update_dairy_queue(score_df):
return diary_id
else:
score_df = score_df.sort_values(by="score", ascending=False)
print("排序后")
print(score_df["cid"].values.tolist())
return score_df["cid"].values.tolist()
......@@ -216,7 +217,8 @@ def update_sql_dairy_queue(queue_name, diary_id):
cursor = db.cursor()
## 去除diary_id 前面的"diary|"
diary_id = json.dumps(list(map(lambda x:x[6:],diary_id)))
print("写入前")
print(diary_id)
sql = "update device_diary_queue set {}='{}' where device_id = '{}'".format(queue_name, diary_id, device_id)
cursor.execute(sql)
db.close()
......@@ -240,7 +242,7 @@ def user_update(device_id):
if not_empty:
name_dict = {"native_queue": native_queue_list, "nearby_queue": nearby_queue_list,
"nation_queue": nation_queue_list, "megacity_queue": megacity_queue_list}
pool = Pool(4)
pool = Pool(1)
for key in name_dict.keys():
pool.apply_async(multi_update, (key, name_dict,native_queue_list,))
pool.close()
......@@ -258,7 +260,7 @@ if __name__ == "__main__":
old_device_id_list = pd.read_csv(DIRECTORY_PATH + "data_set_device_id.csv")["device_id"].values.tolist()
# 求活跃用户和老用户的交集,也就是只预测老用户
predict_list = list(set(device_id_list) & set(old_device_id_list))
predict_list.extend(["B2F0665E-4375-4169-8FE3-8A26A1CFE248","AB20292B-5D15-4C44-9429-1C2FF5ED26F6","358035085192742"])
predict_list.extend(["358035085192742"])
# 只预测尾号是6的ID,这块也可以在数据库取数据时过滤一下
# predict_list = list(filter(lambda x:str(x)[-1] == "6", predict_list))
......@@ -269,6 +271,7 @@ if __name__ == "__main__":
if predict_list != []:
for device_id in predict_list:
user_update(device_id)
else:
print("该列表是新用户,不需要预测")
end = time.time()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment