Skip to content

Commit

Permalink
add some output verbiage and make deletion logic more clear
Browse files Browse the repository at this point in the history
  • Loading branch information
shaneknapp committed Sep 27, 2023
1 parent d724316 commit 8c48f15
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions scripts/delete-unused-users.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,21 @@ async def main():
except:
print(user['last_activity'])
raise
if last_activity and datetime.now().astimezone() - last_activity < timedelta(hours=24) or user['server'] is not None:
delta_bool = datetime.now().astimezone() - last_activity < timedelta(hours=24)
print(f"user: {user['name']}")
print(f"last login: {last_activity}")
print(f"24hrs since last login (bool): {delta_bool}")
print(f"server: {user['server']}")
if (last_activity and delta_bool) or (user['server'] is not None):
print(f"Not deleting {user['name']}")
else:
to_delete.append(user['name'])
print(f"Deleting {user['name']}")
print('')

for i, username in enumerate(to_delete):
print(f'{i+1} of {len(to_delete)}: deleting {username}')
await hub.delete_user(username)
#await hub.delete_user(username)

if __name__ == '__main__':
asyncio.run(main())

0 comments on commit 8c48f15

Please sign in to comment.