Fix bug in print vaultcounts ... account emailaddress (#1493)

This commit is contained in:
Ross Scroggs
2022-03-26 13:42:19 -07:00
committed by GitHub
parent 3b52af0b8a
commit e7496dc9cb

View File

@ -348,7 +348,7 @@ def print_count():
# so we keep track of which accounts we searched and can report # so we keep track of which accounts we searched and can report
# zero data for them. # zero data for them.
if search_method == 'ACCOUNT': if search_method == 'ACCOUNT':
query_accounts = query.get('accountInfo', []) query_accounts = query.get('accountInfo', {}).get('emails', [])
elif search_method == 'ENTIRE_ORG': elif search_method == 'ENTIRE_ORG':
query_accounts = gam.getUsersToModify('all', 'users') query_accounts = gam.getUsersToModify('all', 'users')
elif search_method == 'ORG_UNIT': elif search_method == 'ORG_UNIT':
@ -367,7 +367,8 @@ def print_count():
if account in query_accounts: query_accounts.remove(account) if account in query_accounts: query_accounts.remove(account)
for account in a_count.get('accountCounts', []): for account in a_count.get('accountCounts', []):
email = account.get('account', {}).get('email', '') email = account.get('account', {}).get('email', '')
csv_rows.append({'account': email, 'count': account.get('count')}) if email:
csv_rows.append({'account': email, 'count': account.get('count', 0)})
if email in query_accounts: query_accounts.remove(email) if email in query_accounts: query_accounts.remove(email)
for account in query_accounts: for account in query_accounts:
csv_rows.append({'account': account, 'count': 0}) csv_rows.append({'account': account, 'count': 0})