mirror of
https://github.com/Sea-Haven-Industries/meal-order-manager.git
synced 2026-09-30 08:53:13 +00:00
Apply ruff check --fix and ruff format across all Python files to pass CI pipeline. Remove unused imports (os, sys), fix f-strings without placeholders. Update README to reflect sync-roster Lambda, corrected shared layer path, and current project structure.
58 lines
1.5 KiB
Python
58 lines
1.5 KiB
Python
"""
|
|
Seeds the employee roster into DynamoDB from config.json.
|
|
|
|
Usage: python3 scripts/seed_roster.py
|
|
|
|
Each employee needs: name, email, and slack_user_id (for DM reminders).
|
|
To find Slack user IDs, use the Slack API:
|
|
curl -s -H "Authorization: Bearer $TOKEN" \
|
|
"https://slack.com/api/users.lookupByEmail?email=name@seahavenind.com" \
|
|
| jq .user.id
|
|
"""
|
|
|
|
import json
|
|
import os
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import boto3
|
|
|
|
PROJECT_ROOT = Path(__file__).resolve().parents[1]
|
|
CONFIG_PATH = PROJECT_ROOT / "config.json"
|
|
TABLE_NAME = os.environ.get("TABLE_NAME", "meal-order-manager-orders")
|
|
|
|
|
|
def main():
|
|
with open(CONFIG_PATH) as f:
|
|
config = json.load(f)
|
|
|
|
roster = config.get("roster", [])
|
|
if not roster:
|
|
print("No roster found in config.json", file=sys.stderr)
|
|
sys.exit(1)
|
|
|
|
for emp in roster:
|
|
if "slack_user_id" not in emp:
|
|
emp["slack_user_id"] = ""
|
|
|
|
table = boto3.resource("dynamodb").Table(TABLE_NAME)
|
|
from datetime import datetime
|
|
|
|
table.put_item(
|
|
Item={
|
|
"PK": "CONFIG",
|
|
"SK": "ROSTER",
|
|
"employees": roster,
|
|
"updated_at": datetime.now().isoformat(),
|
|
}
|
|
)
|
|
|
|
print(f"Seeded {len(roster)} employees to DynamoDB")
|
|
for emp in roster:
|
|
sid = emp.get("slack_user_id", "")
|
|
status = "ready" if sid else "MISSING slack_user_id"
|
|
print(f" {emp['name']} ({emp['email']}) — {status}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|