Просмотр исходного кода

Update user_manager: reduce cost of listing user in testing period

StrayWarrior 1 неделя назад
Родитель
Сommit
fb3bd5e2d0
1 измененных файлов с 6 добавлено и 1 удалено
  1. 6 1
      user_manager.py

+ 6 - 1
user_manager.py

@@ -212,7 +212,12 @@ class MySQLUserRelationManager(UserRelationManager):
                 logger.warning(f"staff[{wxid}] has no user")
                 continue
             user_ids = tuple(user['user_id'] for user in user_data)
-            sql = f"SELECT union_id FROM {self.user_table} WHERE id IN {str(user_ids)} AND union_id is not null"
+            # FIXME(zhoutian): 测试期间临时逻辑
+            if agent_staff['third_party_user_id'] == '1688854492669990':
+                sql = f"SELECT union_id FROM {self.user_table} WHERE id IN {str(user_ids)} AND union_id is not null"
+            else:
+                sql = f"SELECT union_id FROM {self.user_table} WHERE id IN {str(user_ids)} AND union_id is not null" \
+                      f" AND id in (SELECT distinct user_id FROM we_com_user_with_tag WHERE tag_id = 15 and is_delete = 0)"
             user_data = self.wecom_db.select(sql, pymysql.cursors.DictCursor)
             if not user_data:
                 logger.warning(f"staff[{wxid}] users not found in wecom database")