Skip to content

Commit

Permalink
💄(api:cli) update groups / operational units ordering
Browse files Browse the repository at this point in the history
When using the `list-groups` command it's more user-friendly to sort
things alphabetically.
  • Loading branch information
jmaupetit committed Dec 16, 2024
1 parent d64e521 commit be1fc42
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ and this project adheres to
- Improve bulk endpoints permissions checking
- Cache logged user object for `API_GET_USER_CACHE_TTL` seconds to decrease the
number of database queries
- CLI: sort groups and operational units alphabetically in the `list-groups`
command

## [0.16.0] - 2024-12-12

Expand Down
4 changes: 2 additions & 2 deletions src/api/qualicharge/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def list_groups(ctx: typer.Context):
"""List API groups."""
session: SMSession = ctx.obj

groups = session.exec(select(Group)).all()
groups = session.exec(select(Group).order_by(Group.name)).all()

table = Table(title="QualiCharge API groups")
table.add_column("Name", justify="right", style="cyan", no_wrap=True)
Expand All @@ -49,7 +49,7 @@ def list_groups(ctx: typer.Context):
table.add_row(
group.name,
",".join(sorted(user.username for user in group.users)),
",".join(ou.code for ou in group.operational_units),
",".join(sorted(ou.code for ou in group.operational_units)),
)
console.print(table)

Expand Down

0 comments on commit be1fc42

Please sign in to comment.