-
Notifications
You must be signed in to change notification settings - Fork 2
/
pull_attendee_data2.sh
executable file
·71 lines (59 loc) · 2.9 KB
/
pull_attendee_data2.sh
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
#######
# This script retrieves attendee data from the pretix API and saves it to a JSON file.
#
# It removes all order secrets, and includes answers to selected questions.
# This script is currently used to render the attendee list of DENOG12, but
# can be easily adapted to your event. It is run using GitHub Workflows.
#
# To run this script, please provide the following variables:
# - api_token: the pretix API token, as per https://docs.pretix.eu/en/latest/api/auth.html
# Create a team that has only read access to the orders of your event.
# - checkin_list is the ID of the checkin list to be used for this attendee list.
# - instance, organizer and event identify your pretix event
####
event="denog15"
api_token="$PRETIX_API_TOKEN"
checkin_list_onsite="$PRETIX_CHECKIN_LIST_ID_ONSITE"
checkin_list_online="$PRETIX_CHECKIN_LIST_ID_ONLINE"
instance="pretix.eu"
organizer="denog"
output_onsite="attendees_${event}_onsite.json"
output_online="attendees_${event}_online.json"
url_onsite="https://$instance/api/v1/organizers/$organizer/events/$event/checkinlists/$checkin_list_onsite/positions/"
url_online="https://$instance/api/v1/organizers/$organizer/events/$event/checkinlists/$checkin_list_online/positions/"
tempfile="response.temp"
datafile="attendees.full"
rm -f "$tempfile"
rm -f "$datafile"
# Attendees onsite
echo "DEBUG: ${url_onsite}"
while [[ $url_onsite != "null" ]]; do
curl -H "Authorization: Token ${api_token}" "${url_onsite}" > ${tempfile}
url_onsite=$(jq -r .next ${tempfile})
jq . ${tempfile} >> $datafile
done
rm -f "$tempfile"
jq -s 'map(.results[]) | map({
name: .attendee_name,
company: ((.answers[] | select(.question_identifier=="COMPANY").answer)//null),
irc: ((.answers[] | select(.question_identifier=="IRC").answer)//null),
asn: ((.answers[] | select(.question_identifier=="ASN").answer)//null),
notpublic: ((.answers[] | select(.question_identifier=="NOTPUBLIC").answer)//null),
})' "$datafile" | jq '[ .[] | select(.notpublic != "True") | {name: .name, company: .company, irc: .irc, asn: .asn} ]' > "_data/${output_onsite}"
rm -f "$datafile"
# Attendees online
echo "DEBUG: ${url_online}"
while [[ $url_online != "null" ]]; do
curl -H "Authorization: Token ${api_token}" "${url_online}" > ${tempfile}
url_online=$(jq -r .next ${tempfile})
jq . ${tempfile} >> $datafile
done
rm -f "$tempfile"
jq -s 'map(.results[]) | map({
name: .attendee_name,
company: ((.answers[] | select(.question_identifier=="COMPANY").answer)//null),
irc: ((.answers[] | select(.question_identifier=="IRC").answer)//null),
asn: ((.answers[] | select(.question_identifier=="ASN").answer)//null),
})' "$datafile" > "_data/$output_online"
rm -f "$datafile"