Skip to content

Commit

Permalink
Better summary for update user roles job (#53)
Browse files Browse the repository at this point in the history
* 🚑 Use sync search and add summary for searches and actions

* Formatted code with black --line-length 120

* better debugging

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
georgepstaylor and github-actions[bot] authored Jul 24, 2024
1 parent c2d35c5 commit 1c51796
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions cli/ldap_cmds/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,9 @@ def update_roles(
log.exception("Failed to connect to LDAP")
raise e

removed = 0
not_removed = 0
failed = 0
for item in cartesian_product:
if add:
try:
Expand Down Expand Up @@ -287,19 +290,19 @@ def update_roles(
failed = failed + 1
else:
log.error("No action specified")

log.info("SUMMARY")
log.info("User/role searches:")
log.info(f"Found {len(roles_found)} users with roles matching the role filter")
log.info(f"Found {len(users_found)} users matching the user filter")

log.info("This produces the following matches:")
log.info(f"Found {len(matched_users)} users with roles matching the role filter and user filter")

log.info("Actions:")
log.info(f"Successfully removed {removed} roles")
log.info(f"Roles already absent for {not_removed} users")
log.info(f"Failed to remove {failed} roles due to errors")
log.info("\n==========================\n\tSUMMARY\n==========================")
log.info("User/role searches:")
log.info(f" - Found {len(roles_found)} users with roles matching the role filter")
log.info(f" - Found {len(users_found)} users matching the user filter")

log.info("This produces the following matches:")
log.info(f" - Found {len(matched_users)} users with roles matching the role filter and user filter")

log.info("Actions:")
log.info(f" - Successfully removed {removed} roles")
log.info(f" - Roles already absent for {not_removed} users")
log.info(f" - Failed to remove {failed} roles due to errors")

if update_notes:
connection = cli.database.connection()
Expand Down

0 comments on commit 1c51796

Please sign in to comment.