summaryrefslogtreecommitdiff
path: root/official-site-scripts/list-events.sh
blob: d56aabf7619be86d524d75931e84b011b3b1318d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env bash
set -euo pipefail

REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
[ -f "$REPO_ROOT/.env" ] && set -a && source "$REPO_ROOT/.env" && set +a

AWS_CLI="${AWS_CLI:-/tmp/awscli/aws/dist/aws}"
ENDPOINT="${APP_SYNC_ENDPOINT:?APP_SYNC_ENDPOINT not set}"
API_KEY="${APP_SYNC_API_KEY:?APP_SYNC_API_KEY not set}"

QUERY='{ listEvents(limit: 200) { items { id type date title venueName published shortTitle ticketFee key } } }'

curl -s -X POST "$ENDPOINT" \
  -H "Content-Type: application/json" \
  -H "x-api-key: $API_KEY" \
  -d "{\"query\": $(echo "$QUERY" | python3 -c 'import json,sys; print(json.dumps(sys.stdin.read()))')}" \
| python3 -c "
import json, sys
d = json.load(sys.stdin)
items = d['data']['listEvents']['items']
items.sort(key=lambda x: x['date'] or '')
for e in items:
    pub = '✓' if e['published'] else ' '
    print(f\"[{pub}] {e['date']}  {e['title'][:50]:<50}  {e['venueName'] or ''}\")
"