Skip to content
Snippets Groups Projects
Commit 94fa00ef authored by Marcus's avatar Marcus
Browse files

shorten username in pooled mode to respect 32 char limit

parent 087726f6
No related branches found
No related tags found
No related merge requests found
Pipeline #408436 failed
......@@ -126,5 +126,10 @@ class PooledNameGenerator:
self.index += 1
if self.index >= 10**self.digits:
return None
candidate_name = f"{self.username_prefix}%0{self.digits}d" % self.index
candidate_name_no_digits = f"{self.username_prefix}"
potential_length = len(candidate_name_no_digits) + self.digits
if potential_length > 32:
excess_chars = potential_length - 32
candidate_name_no_digits = candidate_name_no_digits[:-excess_chars]
candidate_name = f"{candidate_name_no_digits}%0{self.digits}d" % self.index
return candidate_name
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment