|
@@ -253,10 +253,7 @@ class MySQLUserRelationManager(UserRelationManager):
|
|
return []
|
|
return []
|
|
|
|
|
|
def list_staff_users(self, staff_id: str = None, tag_id: int = None):
|
|
def list_staff_users(self, staff_id: str = None, tag_id: int = None):
|
|
- # FIXME(zhoutian)
|
|
|
|
- # 测试期间逻辑,只取一个账号
|
|
|
|
sql = f"SELECT third_party_user_id, wxid FROM {self.agent_staff_table} WHERE status = 1"
|
|
sql = f"SELECT third_party_user_id, wxid FROM {self.agent_staff_table} WHERE status = 1"
|
|
- # f" AND third_party_user_id in ('1688854492669990', '1688855931724582')")
|
|
|
|
if staff_id:
|
|
if staff_id:
|
|
sql += f" AND third_party_user_id = '{staff_id}'"
|
|
sql += f" AND third_party_user_id = '{staff_id}'"
|
|
agent_staff_data = self.agent_db.select(sql, pymysql.cursors.DictCursor)
|
|
agent_staff_data = self.agent_db.select(sql, pymysql.cursors.DictCursor)
|
|
@@ -277,7 +274,6 @@ class MySQLUserRelationManager(UserRelationManager):
|
|
logger.warning(f"staff[{wxid}] has no user")
|
|
logger.warning(f"staff[{wxid}] has no user")
|
|
continue
|
|
continue
|
|
user_ids = tuple(user['user_id'] for user in user_data)
|
|
user_ids = tuple(user['user_id'] for user in user_data)
|
|
- # FIXME(zhoutian): 测试期间临时逻辑
|
|
|
|
sql = f"SELECT union_id FROM {self.user_table} WHERE id IN {str(user_ids)} AND union_id is not null"
|
|
sql = f"SELECT union_id FROM {self.user_table} WHERE id IN {str(user_ids)} AND union_id is not null"
|
|
if tag_id:
|
|
if tag_id:
|
|
sql += f" AND id in (SELECT distinct user_id FROM we_com_user_with_tag WHERE tag_id = {tag_id} and is_delete = 0)"
|
|
sql += f" AND id in (SELECT distinct user_id FROM we_com_user_with_tag WHERE tag_id = {tag_id} and is_delete = 0)"
|
|
@@ -286,7 +282,7 @@ class MySQLUserRelationManager(UserRelationManager):
|
|
logger.warning(f"staff[{wxid}] users not found in wecom database")
|
|
logger.warning(f"staff[{wxid}] users not found in wecom database")
|
|
continue
|
|
continue
|
|
user_union_ids = tuple(user['union_id'] for user in user_data)
|
|
user_union_ids = tuple(user['union_id'] for user in user_data)
|
|
- batch_size = 100
|
|
|
|
|
|
+ batch_size = 500
|
|
n_batches = (len(user_union_ids) + batch_size - 1) // batch_size
|
|
n_batches = (len(user_union_ids) + batch_size - 1) // batch_size
|
|
agent_user_data = []
|
|
agent_user_data = []
|
|
for i in range(n_batches):
|
|
for i in range(n_batches):
|