liqian 2 年之前
父節點
當前提交
9da0540b03
共有 1 個文件被更改,包括 10 次插入4 次删除
  1. 10 4
      words_func.py

+ 10 - 4
words_func.py

@@ -98,11 +98,17 @@ def update_wechat_score_data(data):
                 update_sql_values = ' '.join([f"when {item['id']} then {item['score']}" for item in update_temp_data])
                 update_sql_values = ' '.join([f"when {item['id']} then {item['score']}" for item in update_temp_data])
                 update_start_time = time.time()
                 update_start_time = time.time()
                 if len(update_id) > 1:
                 if len(update_id) > 1:
-                    update_sql = f"update word.word_wechat_score set wechat_score = " \
-                                 f"case id {update_sql_values} end where id in {tuple(update_id)};"
+                    update_sql = \
+                        f"""update word.word_wechat_score set wechat_score = case id {update_sql_values} end, 
+                        update_time = '{datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")}' 
+                        where id in {tuple(update_id)};"""
                 else:
                 else:
-                    update_sql = f"update word.word_wechat_score set wechat_score = " \
-                                 f"case id {update_sql_values} end where id in ({update_id[0]});"
+                    update_sql = \
+                        f"""update word.word_wechat_score set wechat_score = case id {update_sql_values} end, 
+                                            update_time = '{datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")}' 
+                                            where id in ({update_id[0]});"""
+                        # f"update word.word_wechat_score set wechat_score = " \
+                        #          f"case id {update_sql_values} end where id in ({update_id[0]});"
                 mysql_helper.add_data(sql=update_sql)
                 mysql_helper.add_data(sql=update_sql)
                 log_.info(f"update executeTime: {(time.time() - update_start_time) * 1000}")
                 log_.info(f"update executeTime: {(time.time() - update_start_time) * 1000}")
     log_.info(f"update wechat score data finished! update count = {len(update_data)}")
     log_.info(f"update wechat score data finished! update count = {len(update_data)}")