Commit a483ecdc authored by 张彦钊's avatar 张彦钊

update diaryqueue

parent d9ed33cc
......@@ -112,13 +112,14 @@ def predict(queue_name, x_list):
ffm_model.predict(DIRECTORY_PATH + "model.out",
DIRECTORY_PATH + "result/output{0}_{1}.csv".format(device_id,queue_name))
save_result(queue_name, x_list)
print("done predict")
def save_result(queue_name, x_list):
score_df = pd.read_csv(DIRECTORY_PATH + "result/output{0}_{1}.csv".format(device_id,queue_name), header=None)
score_df = score_df.rename(columns={0: "score"})
score_df["cid"] = x_list
print("done save_reult")
merge_score(x_list, score_df)
......@@ -126,6 +127,8 @@ def merge_score(x_list, score_df):
db = pymysql.connect(host='10.66.157.22', port=4000, user='root',passwd='3SYz54LS9#^9sBvC', db='eagle')
cursor = db.cursor()
score_list = []
# 去除diary_id 前面的"diary|"
x_list = list(map(lambda x:x[6:],x_list))
for i in x_list:
sql = "select score from biz_feed_diary_score where diary_id = '{}';".format(i)
cursor.execute(sql)
......@@ -173,6 +176,8 @@ def update_sql_dairy_queue(queue_name, diary_id):
db = pymysql.connect(host='rm-m5e842126ng59jrv6.mysql.rds.aliyuncs.com', port=3306, user='doris',
passwd='o5gbA27hXHHm', db='doris_prod')
cursor = db.cursor()
## 去除diary_id 前面的"diary|"
diary_id = list(map(lambda x:x[6:],diary_id))
sql = "update device_diary_queue set {}='{}' where device_id = '{}'".format(queue_name, diary_id, device_id)
cursor.execute(sql)
db.close()
......
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