소스 검색

Add tools/profile_cleaner

StrayWarrior 1 주 전
부모
커밋
0275d5dcb5
1개의 변경된 파일26개의 추가작업 그리고 0개의 파일을 삭제
  1. 26 0
      tools/profile_cleaner.py

+ 26 - 0
tools/profile_cleaner.py

@@ -0,0 +1,26 @@
+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
+# vim:fenc=utf-8
+
+"""
+用户画像信息提取在不断迭代中,可能需清除旧的用户画像信息避免干扰,故提供此工具
+"""
+import sys
+import os
+sys.path.append(os.curdir)
+import configs
+from user_manager import MySQLUserManager
+
+if __name__ == '__main__':
+    config = configs.get()
+    user_db_config = config['storage']['user']
+    staff_db_config = config['storage']['staff']
+    user_manager = MySQLUserManager(user_db_config['mysql'], user_db_config['table'], staff_db_config['table'])
+
+    user_ids_to_clean = ['7881299986081786', '7881303544096524', '7881300732152777', '7881301752098239', '7881299457990953', '7881302872936170',]
+    for user_id in user_ids_to_clean:
+        profile = user_manager.get_user_profile(user_id)
+        profile['name'] = ''
+        profile['preferred_nickname'] = ''
+        user_manager.save_user_profile(user_id, profile)
+