generated from nhcarrigan/template
a40188413a
All Python cohort scripts now use DATA_DIR = Path(__file__).parent.parent.parent / "data" to correctly resolve the repo-root data/ directory regardless of the working directory set by run.sh. All TypeScript scripts have expanded JSDoc headers documenting data file requirements and environment variables.
64 lines
2.1 KiB
Python
64 lines
2.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Remove resigned members from team_assignments.json.
|
|
|
|
Update RESIGNED_IDS with the Discord IDs of members who have resigned
|
|
before running this script.
|
|
"""
|
|
|
|
import json
|
|
from pathlib import Path
|
|
|
|
DATA_DIR = Path(__file__).parent.parent.parent / "data"
|
|
|
|
# Discord IDs of members who have resigned - update before running
|
|
RESIGNED_IDS: list[str] = []
|
|
|
|
|
|
def main() -> None:
|
|
"""Remove resigned members from team assignments."""
|
|
with open(DATA_DIR / "team_assignments.json") as f:
|
|
teams = json.load(f)
|
|
|
|
changes_made = []
|
|
|
|
for team in teams:
|
|
team_name = team["name"]
|
|
|
|
original_leaders = len(team["leaders"])
|
|
team["leaders"] = [lid for lid in team["leaders"] if lid not in RESIGNED_IDS]
|
|
if len(team["leaders"]) < original_leaders:
|
|
removed = original_leaders - len(team["leaders"])
|
|
changes_made.append(f"Removed {removed} leader(s) from {team_name}")
|
|
|
|
original_participants = len(team["participants"])
|
|
team["participants"] = [
|
|
pid for pid in team["participants"] if pid not in RESIGNED_IDS
|
|
]
|
|
if len(team["participants"]) < original_participants:
|
|
removed = original_participants - len(team["participants"])
|
|
changes_made.append(f"Removed {removed} participant(s) from {team_name}")
|
|
print(f"⚠️ {team_name}: Proficiency distribution may need updating")
|
|
|
|
with open(DATA_DIR / "team_assignments.json", "w") as f:
|
|
json.dump(teams, f, indent=2)
|
|
|
|
if changes_made:
|
|
print("✅ Successfully removed resigned members from team_assignments.json")
|
|
print("\nChanges made:")
|
|
for change in changes_made:
|
|
print(f" - {change}")
|
|
else:
|
|
print("No changes needed - resigned members were not found in team assignments")
|
|
|
|
print("\nUpdated team sizes:")
|
|
for team in teams:
|
|
total_members = len(team["leaders"]) + len(team["participants"])
|
|
print(
|
|
f" {team['name']}: {total_members} members "
|
|
f"({len(team['leaders'])} leaders, {len(team['participants'])} participants)" # noqa: E501
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|