generated from nhcarrigan/template
feat: port remaining cohort scripts and make reusable
- Port 19 cohort scripts from /home/naomi/docs/cohort/ - Replace all hardcoded tokens and dotenv usage with os.environ - Add pandas==3.0.1 dependency - Add E501 to ruff ignore list for Discord message string content - Make remove_resigned_members.py reusable (empty RESIGNED_IDS constant) - Make update_roster_messages.py reusable (iterates all teams from JSON) - Exclude 12 one-off/event-specific scripts as non-reusable
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
#!/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
|
||||
|
||||
# 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("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("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()
|
||||
Reference in New Issue
Block a user