Some users were nervous about the round portion of the channel name
overwhelming the space available for channel names, making it
impossible to distinguish one puzzle channel from another in the same
round. Restricting the round prefix to only 7 letters should help
mitigate that.
def puzzle_id_from_name(name):
return re.sub(r'[^a-zA-Z0-9_]', '', name).lower()
+def round_id_from_name(name):
+ """Normalize and abbreviate round name for use as a prefix
+ in a channel name."""
+
+ return re.sub(r'[^a-zA-Z0-9_]', '', name).lower()[:7]
+
def puzzle_sort_key(puzzle):
"""Return an appropriate sort key for a puzzle in the database
round = ''
if 'rounds' in puzzle:
- round = '-' + puzzle_id_from_name(puzzle['rounds'][0])
+ round = '-' + round_id_from_name(puzzle['rounds'][0])
meta = ''
if puzzle.get('type', 'plain') == 'meta':