mirror of
https://github.com/Sea-Haven-Industries/afterhours-shift-manager.git
synced 2026-09-30 13:43:12 +00:00
90 lines
2.5 KiB
Python
90 lines
2.5 KiB
Python
|
|
#!/usr/bin/env python3
|
||
|
|
"""Seed the afterhours-shifts DynamoDB table with initial roster and schedule.
|
||
|
|
|
||
|
|
Usage:
|
||
|
|
python scripts/seed_schedule.py # uses default table name
|
||
|
|
python scripts/seed_schedule.py --table my-table # custom table name
|
||
|
|
"""
|
||
|
|
|
||
|
|
import argparse
|
||
|
|
|
||
|
|
import boto3
|
||
|
|
|
||
|
|
|
||
|
|
TABLE_NAME = "afterhours-shifts"
|
||
|
|
|
||
|
|
ROSTER = [
|
||
|
|
{"extension": "100", "name": "Adam Moussa"},
|
||
|
|
{"extension": "111", "name": "Alyssa Ficarra"},
|
||
|
|
{"extension": "113", "name": "Sarah May"},
|
||
|
|
{"extension": "114", "name": "Ashley Fedner"},
|
||
|
|
{"extension": "115", "name": "Derrick Smith"},
|
||
|
|
{"extension": "116", "name": "Cindy Vallecillo"},
|
||
|
|
]
|
||
|
|
|
||
|
|
WEEKLY_SCHEDULE = {
|
||
|
|
"Monday": {"extension": "114", "name": "Ashley Fedner"},
|
||
|
|
"Tuesday": {"extension": "115", "name": "Derrick Smith"},
|
||
|
|
"Wednesday": {"extension": "114", "name": "Ashley Fedner"},
|
||
|
|
"Thursday": {"extension": "115", "name": "Derrick Smith"},
|
||
|
|
"Friday": {"extension": "116", "name": "Cindy Vallecillo"},
|
||
|
|
"Saturday": {"extension": "100", "name": "Fallback"},
|
||
|
|
"Sunday": {"extension": "100", "name": "Fallback"},
|
||
|
|
}
|
||
|
|
|
||
|
|
CONFIG = {
|
||
|
|
"ring_group": "800",
|
||
|
|
"fallback_extension": "100",
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
def seed(table_name: str):
|
||
|
|
dynamodb = boto3.resource("dynamodb")
|
||
|
|
table = dynamodb.Table(table_name)
|
||
|
|
|
||
|
|
print(f"Seeding table: {table_name}")
|
||
|
|
|
||
|
|
# Roster
|
||
|
|
for emp in ROSTER:
|
||
|
|
table.put_item(
|
||
|
|
Item={
|
||
|
|
"PK": "ROSTER",
|
||
|
|
"SK": emp["extension"],
|
||
|
|
"name": emp["name"],
|
||
|
|
"extension": emp["extension"],
|
||
|
|
"slack_user_id": "",
|
||
|
|
}
|
||
|
|
)
|
||
|
|
print(f" Roster: Ext {emp['extension']} — {emp['name']}")
|
||
|
|
|
||
|
|
# Weekly schedule
|
||
|
|
for day, info in WEEKLY_SCHEDULE.items():
|
||
|
|
table.put_item(
|
||
|
|
Item={
|
||
|
|
"PK": "WEEKLY",
|
||
|
|
"SK": day,
|
||
|
|
"extension": info["extension"],
|
||
|
|
"name": info["name"],
|
||
|
|
}
|
||
|
|
)
|
||
|
|
print(f" Weekly: {day} — {info['name']} (Ext {info['extension']})")
|
||
|
|
|
||
|
|
# Config
|
||
|
|
table.put_item(
|
||
|
|
Item={
|
||
|
|
"PK": "CONFIG",
|
||
|
|
"SK": "CONFIG",
|
||
|
|
**CONFIG,
|
||
|
|
}
|
||
|
|
)
|
||
|
|
print(f" Config: ring_group={CONFIG['ring_group']}, fallback={CONFIG['fallback_extension']}")
|
||
|
|
|
||
|
|
print("\nDone! Employees should run `/oncall register <extension>` in Slack to link their accounts.")
|
||
|
|
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
parser = argparse.ArgumentParser()
|
||
|
|
parser.add_argument("--table", default=TABLE_NAME)
|
||
|
|
args = parser.parse_args()
|
||
|
|
seed(args.table)
|