liqian %!s(int64=2) %!d(string=hai) anos
pai
achega
9da0540b03
Modificáronse 1 ficheiros con 10 adicións e 4 borrados
  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_start_time = time.time()
                 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:
-                    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)
                 log_.info(f"update executeTime: {(time.time() - update_start_time) * 1000}")
     log_.info(f"update wechat score data finished! update count = {len(update_data)}")