#!/bin/bash
# Update Grist tracker with clean weekly batches
# Week 1 = users with email sent (7 users, IDs 2-8)
# Already enrolled = 6 users (IDs 1, 15, 23, 24, 54, 62)
# Weeks 2-11 = remaining 50 users, 5 per week

TOKEN="014e69…bd41"
DOC_ID="wmBGUbgBveCdeY8fZ6T6eL"
API_URL="https://grist.beawit.net/api/docs/$DOC_ID/tables/Intune/records"

curl -sk "$API_URL" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -X PATCH \
  -d '{"records":[
    {"id":1,"fields":{"Batch":"Enrolled"}},
    {"id":2,"fields":{"Batch":"Week 1 (Jul 21)"}},
    {"id":3,"fields":{"Batch":"Week 1 (Jul 21)"}},
    {"id":4,"fields":{"Batch":"Week 1 (Jul 21)"}},
    {"id":5,"fields":{"Batch":"Week 1 (Jul 21)"}},
    {"id":6,"fields":{"Batch":"Week 1 (Jul 21)"}},
    {"id":7,"fields":{"Batch":"Week 1 (Jul 21)"}},
    {"id":8,"fields":{"Batch":"Week 1 (Jul 21)"}},
    {"id":9,"fields":{"Batch":"Week 2 (Jul 28)"}},
    {"id":10,"fields":{"Batch":"Week 2 (Jul 28)"}},
    {"id":11,"fields":{"Batch":"Week 2 (Jul 28)"}},
    {"id":12,"fields":{"Batch":"Week 2 (Jul 28)"}},
    {"id":13,"fields":{"Batch":"Week 2 (Jul 28)"}},
    {"id":14,"fields":{"Batch":"Week 3 (Aug 4)"}},
    {"id":15,"fields":{"Batch":"Enrolled"}},
    {"id":16,"fields":{"Batch":"Week 3 (Aug 4)"}},
    {"id":17,"fields":{"Batch":"Week 3 (Aug 4)"}},
    {"id":18,"fields":{"Batch":"Week 3 (Aug 4)"}},
    {"id":19,"fields":{"Batch":"Week 4 (Aug 11)"}},
    {"id":20,"fields":{"Batch":"Week 4 (Aug 11)"}},
    {"id":21,"fields":{"Batch":"Week 4 (Aug 11)"}},
    {"id":22,"fields":{"Batch":"Week 4 (Aug 11)"}},
    {"id":23,"fields":{"Batch":"Enrolled"}},
    {"id":24,"fields":{"Batch":"Enrolled"}},
    {"id":25,"fields":{"Batch":"Week 5 (Aug 18)"}},
    {"id":26,"fields":{"Batch":"Week 5 (Aug 18)"}},
    {"id":27,"fields":{"Batch":"Week 5 (Aug 18)"}},
    {"id":28,"fields":{"Batch":"Week 5 (Aug 18)"}},
    {"id":29,"fields":{"Batch":"Week 5 (Aug 18)"}},
    {"id":30,"fields":{"Batch":"Week 6 (Aug 25)"}},
    {"id":31,"fields":{"Batch":"Week 6 (Aug 25)"}},
    {"id":32,"fields":{"Batch":"Week 6 (Aug 25)"}},
    {"id":33,"fields":{"Batch":"Week 6 (Aug 25)"}},
    {"id":34,"fields":{"Batch":"Week 6 (Aug 25)"}},
    {"id":35,"fields":{"Batch":"Week 7 (Sep 1)"}},
    {"id":36,"fields":{"Batch":"Week 7 (Sep 1)"}},
    {"id":37,"fields":{"Batch":"Week 7 (Sep 1)"}},
    {"id":38,"fields":{"Batch":"Week 7 (Sep 1)"}},
    {"id":39,"fields":{"Batch":"Week 7 (Sep 1)"}},
    {"id":40,"fields":{"Batch":"Week 8 (Sep 8)"}},
    {"id":41,"fields":{"Batch":"Week 8 (Sep 8)"}},
    {"id":42,"fields":{"Batch":"Week 8 (Sep 8)"}},
    {"id":43,"fields":{"Batch":"Week 8 (Sep 8)"}},
    {"id":44,"fields":{"Batch":"Week 8 (Sep 8)"}},
    {"id":45,"fields":{"Batch":"Week 9 (Sep 15)"}},
    {"id":46,"fields":{"Batch":"Week 9 (Sep 15)"}},
    {"id":47,"fields":{"Batch":"Week 9 (Sep 15)"}},
    {"id":48,"fields":{"Batch":"Week 9 (Sep 15)"}},
    {"id":49,"fields":{"Batch":"Week 9 (Sep 15)"}},
    {"id":50,"fields":{"Batch":"Week 10 (Sep 22)"}},
    {"id":51,"fields":{"Batch":"Week 10 (Sep 22)"}},
    {"id":52,"fields":{"Batch":"Week 10 (Sep 22)"}},
    {"id":53,"fields":{"Batch":"Week 10 (Sep 22)"}},
    {"id":54,"fields":{"Batch":"Enrolled"}},
    {"id":55,"fields":{"Batch":"Week 11 (Sep 29)"}},
    {"id":56,"fields":{"Batch":"Week 11 (Sep 29)"}},
    {"id":57,"fields":{"Batch":"Week 11 (Sep 29)"}},
    {"id":58,"fields":{"Batch":"Week 11 (Sep 29)"}},
    {"id":59,"fields":{"Batch":"Week 11 (Sep 29)"}},
    {"id":60,"fields":{"Batch":"Week 11 (Sep 29)"}},
    {"id":61,"fields":{"Batch":"Week 11 (Sep 29)"}},
    {"id":62,"fields":{"Batch":"Enrolled"}},
    {"id":63,"fields":{"Batch":"Week 11 (Sep 29)"}}
  ]}'

echo "Grist update complete - clean batch assignments"