Get list of users from trust group, increase rails timeout
This commit is contained in:
parent
50d455920c
commit
24a0f37faa
|
@ -84,7 +84,7 @@ def discourse_api_delete(url, data={}):
|
||||||
|
|
||||||
def discourse_rails_script(script):
|
def discourse_rails_script(script):
|
||||||
result = subprocess.run(['docker', 'exec', '-i', secrets.DISCOURSE_CONTAINER, 'rails', 'runner', script],
|
result = subprocess.run(['docker', 'exec', '-i', secrets.DISCOURSE_CONTAINER, 'rails', 'runner', script],
|
||||||
shell=False, text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=30)
|
shell=False, text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=60)
|
||||||
output = result.stdout or result.stderr
|
output = result.stdout or result.stderr
|
||||||
output = output.strip() or 'No complaints'
|
output = output.strip() or 'No complaints'
|
||||||
return result, output
|
return result, output
|
||||||
|
@ -99,24 +99,15 @@ def get_discourse_group_id(group_name):
|
||||||
|
|
||||||
def get_discourse_usernames():
|
def get_discourse_usernames():
|
||||||
usernames = []
|
usernames = []
|
||||||
page = 1
|
|
||||||
|
|
||||||
for _ in range(10):
|
response = discourse_api_get('https://forum.protospace.ca/groups/trust_level_0/members.json?limit=1000')
|
||||||
params = {
|
response = response.json()
|
||||||
'page': page,
|
|
||||||
}
|
|
||||||
response = discourse_api_get('https://forum.protospace.ca/admin/users/list/active.json', params)
|
|
||||||
response = response.json()
|
|
||||||
|
|
||||||
if not len(response):
|
for user in response['members']:
|
||||||
break
|
usernames.append(user['username'])
|
||||||
|
|
||||||
for u in response:
|
if len(usernames) == 1000:
|
||||||
usernames.append(u['username'])
|
logger.error('Hit username limit, aborting!')
|
||||||
|
|
||||||
page += 1
|
|
||||||
else: # for
|
|
||||||
logger.error('Too many user pages, aborting')
|
|
||||||
abort(400)
|
abort(400)
|
||||||
|
|
||||||
return usernames
|
return usernames
|
||||||
|
|
Loading…
Reference in New Issue
Block a user