fix: strip tag decorators from squadron names in comp writer and /comp lookup

Squads with dash or underscore tags (e.g. -DSPLA-, _APS_) had their raw
replay team.squadron value written directly to COMPS filenames, producing
-DSPLA-.json / _APS_.json. The /comp autocomplete returns the clean DB
short_name (DSPLA) so the file lookup never matched.

Fix: strip leading/trailing non-alphanumeric characters and uppercase in
both the writer and the /comp command lookup. Also renamed the 8 existing
decorated COMPS files to their clean equivalents on disk.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
deploy
2026-05-29 18:15:48 +00:00
parent 1d5da8042c
commit 0154c41997
2 changed files with 4 additions and 3 deletions
+2 -2
View File
@@ -1757,8 +1757,8 @@ async def process_comps(new_games):
# Compare to existing comps and write new/updated ones # Compare to existing comps and write new/updated ones
for team in replay_data.get("teams", []): for team in replay_data.get("teams", []):
squadron = team.get("squadron", "UNKNOWN") squadron = re.sub(r'^[^A-Za-z0-9]+|[^A-Za-z0-9]+$', '',
squadron = squadron.upper() team.get("squadron", "UNKNOWN")).upper() or "UNKNOWN"
squad_file = comp_dir / f"{squadron}.json" squad_file = comp_dir / f"{squadron}.json"
# Load existing comps_data (or start fresh) # Load existing comps_data (or start fresh)
+2 -1
View File
@@ -521,7 +521,8 @@ async def comp(interaction: discord.Interaction, squadron_short: str):
comp_footer = f"{comp_footer}\n{ttl_footer}" if comp_footer else ttl_footer comp_footer = f"{comp_footer}\n{ttl_footer}" if comp_footer else ttl_footer
comp_dir = STORAGE_DIR / "COMPS" comp_dir = STORAGE_DIR / "COMPS"
squad_file = comp_dir / f"{squadron_short}.json" squadron_key = re.sub(r'^[^A-Za-z0-9]+|[^A-Za-z0-9]+$', '', squadron_short).upper() or squadron_short.upper()
squad_file = comp_dir / f"{squadron_key}.json"
if not squad_file.exists(): if not squad_file.exists():
return await interaction.followup.send( return await interaction.followup.send(
embed=discord.Embed( embed=discord.Embed(