fix weekly br selector (#1249)
This commit is contained in:
+6
-9
@@ -857,7 +857,7 @@ async def quick_log_error(interaction, error):
|
|||||||
|
|
||||||
|
|
||||||
def _pick_test_br_window() -> Optional[Dict[str, Any]]:
|
def _pick_test_br_window() -> Optional[Dict[str, Any]]:
|
||||||
"""Return the BR window enclosing now, else the most recently ended one."""
|
"""Return the most recently ended BR window (mirrors the real scheduled task)."""
|
||||||
schedule_path = Path(__file__).parent / "SCHEDULE.json"
|
schedule_path = Path(__file__).parent / "SCHEDULE.json"
|
||||||
try:
|
try:
|
||||||
with open(schedule_path, "r", encoding="utf-8") as fp:
|
with open(schedule_path, "r", encoding="utf-8") as fp:
|
||||||
@@ -867,27 +867,21 @@ def _pick_test_br_window() -> Optional[Dict[str, Any]]:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
now_ts = int(time_module.time())
|
now_ts = int(time_module.time())
|
||||||
active = None
|
|
||||||
most_recent_past = None
|
most_recent_past = None
|
||||||
for entry in schedule:
|
for entry in schedule:
|
||||||
try:
|
try:
|
||||||
s = int(entry["start"])
|
|
||||||
e = int(entry["end"])
|
e = int(entry["end"])
|
||||||
except (KeyError, TypeError, ValueError):
|
except (KeyError, TypeError, ValueError):
|
||||||
continue
|
continue
|
||||||
if s <= now_ts <= e:
|
|
||||||
active = entry
|
|
||||||
break
|
|
||||||
if e < now_ts and (most_recent_past is None or e > int(most_recent_past["end"])):
|
if e < now_ts and (most_recent_past is None or e > int(most_recent_past["end"])):
|
||||||
most_recent_past = entry
|
most_recent_past = entry
|
||||||
return active or most_recent_past
|
return most_recent_past
|
||||||
|
|
||||||
|
|
||||||
@is_blacklisted()
|
@is_blacklisted()
|
||||||
@is_admin()
|
|
||||||
@bot.tree.command(
|
@bot.tree.command(
|
||||||
name="test-weekly-br",
|
name="test-weekly-br",
|
||||||
description="[Admin] Preview the Weekly BR Report for the current/most-recent BR window",
|
description="[DEV] Preview the Weekly BR Report for the current/most-recent BR window",
|
||||||
)
|
)
|
||||||
@app_commands.describe(
|
@app_commands.describe(
|
||||||
squadron_name="Optional: also send the per-squadron variant for this squadron",
|
squadron_name="Optional: also send the per-squadron variant for this squadron",
|
||||||
@@ -909,6 +903,9 @@ async def test_weekly_br(
|
|||||||
)
|
)
|
||||||
|
|
||||||
await collect_command_stats(interaction)
|
await collect_command_stats(interaction)
|
||||||
|
if not await is_dev_team(interaction):
|
||||||
|
await interaction.response.send_message(t("en", "dev.restricted_dev_team"), ephemeral=True)
|
||||||
|
return
|
||||||
await interaction.response.defer(ephemeral=False)
|
await interaction.response.defer(ephemeral=False)
|
||||||
|
|
||||||
lang = await guild_lang(interaction.guild.id) if interaction.guild else "en"
|
lang = await guild_lang(interaction.guild.id) if interaction.guild else "en"
|
||||||
|
|||||||
Reference in New Issue
Block a user