Commit ba6a085e authored by 段英荣's avatar 段英荣

Merge branch 'sync_tx' into 'master'

modify

See merge request !191
parents ba8dcb36 82dc34f2
...@@ -119,15 +119,19 @@ class User(models.Model): ...@@ -119,15 +119,19 @@ class User(models.Model):
def get_same_group_user_id_list(self): def get_same_group_user_id_list(self):
same_group_user_id_list = list() same_group_user_id_list = list()
group_items_list = GroupUserRole.objects.using(settings.SLAVE_DB_NAME).filter(user_id=self.user_id) group_items_list = list(GroupUserRole.objects.using(settings.SLAVE_DB_NAME).filter(user_id=self.user_id).values_list("group_id").limit(100))
for group_item in group_items_list: for group_id in group_items_list:
group_id = group_item.group_id user_items_list = list(GroupUserRole.objects.using(settings.SLAVE_DB_NAME).filter(group_id=group_id).values_list("user_id").limit(100))
user_items_list = GroupUserRole.objects.using(settings.SLAVE_DB_NAME).filter(group_id=group_id) for user_id in user_items_list:
for user_items_list in user_items_list: same_group_user_id_list.append(user_id)
same_group_user_id_list.append(user_items_list.user_id) if len(same_group_user_id_list)>=100:
break
if len(same_group_user_id_list)>=100:
break
same_group_detail_list = list() same_group_detail_list = list()
for i in range(0, len(same_group_user_id_list), 1000): for i in range(0, len(same_group_user_id_list), 200):
sql_data_list = User.objects.using(settings.SLAVE_DB_NAME).filter(user_id__in=same_group_user_id_list[i:i + 1000]) sql_data_list = User.objects.using(settings.SLAVE_DB_NAME).filter(user_id__in=same_group_user_id_list[i:i + 1000])
for detail_data in sql_data_list: for detail_data in sql_data_list:
item = { item = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment