Skip to content

Commit

Permalink
Add some code comments for clarity.
Browse files Browse the repository at this point in the history
  • Loading branch information
dbernstein committed Jan 9, 2024
1 parent 05d1fc7 commit 18c4009
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions api/admin/controller/quicksight.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,23 +121,33 @@ def append_to_session_tags():
)

delimiter = "|"
# specified by AWS's session tag limit
max_chars_per_tag = 256

session_tags: list[dict[Any, str]] = []

if len(short_names) == 0:
return session_tags

Check warning on line 130 in api/admin/controller/quicksight.py

View check run for this annotation

Codecov / codecov/patch

api/admin/controller/quicksight.py#L130

Added line #L130 was not covered by tests

per_tag_character_count = 0
tag_index = 0
tag_values = []
for short_name in short_names:
# add one for the delimiter
chars_to_be_added = len(short_name) + 1
# Add values as long as they will not exceed the maximum limit
if chars_to_be_added + per_tag_character_count <= max_chars_per_tag:
tag_values.append(short_name)
per_tag_character_count += chars_to_be_added
else:
# otherwise append the tag and values and start a new tag with
# a new list of values
append_to_session_tags()
per_tag_character_count = chars_to_be_added
tag_values = [short_name]
tag_index += 1

# append the un-appended tag and values
append_to_session_tags()

return session_tags
Expand Down

0 comments on commit 18c4009

Please sign in to comment.