-
Notifications
You must be signed in to change notification settings - Fork 1
feat(api): add account creation automation shell script #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds a new Bash script to automate creating user accounts via the Prolific admin API by selecting a random subset of participants from a TSV file.
- Introduces
create_accounts.shto handle input parsing, random sampling, JSON construction, and bulk API requests. - Validates the input file exists and enforces strict error handling with
set -euo pipefail.
Comments suppressed due to low confidence (2)
create_accounts.sh:14
- [nitpick] This comment duplicates the previous line—consider removing or merging it to avoid redundancy.
# The script will also print the number of accounts created.
create_accounts.sh:19
- The
API_KEYassignment is missing a closing double quote, causing a syntax error. Add the closing".
API_KEY="api_key_here
| while IFS=$'\t' read -r _ pair; do | ||
| IFS='|' read -r email id <<< "$pair" | ||
| users_json+=$( | ||
| printf '{"name":"Prolific ID: %s","email":"%s","position":"Physician Assistant (PA)","employer":"n/a","area_of_clinical_ex":"n/a"},' \ | ||
| "$id" "$email" | ||
| ) | ||
| count=$((count+1)) | ||
| [ "$count" -ge "$NUM_SAMPLES" ] && break | ||
| done < <(random_stream) |
Copilot
AI
Jun 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The script ignores the first column (Occupation/Specialty) and hardcodes position, employer, etc. Unpack all three fields (e.g., read -r occupation email id) and use "$occupation" instead of a fixed string to keep data accurate.
| while IFS=$'\t' read -r _ pair; do | |
| IFS='|' read -r email id <<< "$pair" | |
| users_json+=$( | |
| printf '{"name":"Prolific ID: %s","email":"%s","position":"Physician Assistant (PA)","employer":"n/a","area_of_clinical_ex":"n/a"},' \ | |
| "$id" "$email" | |
| ) | |
| count=$((count+1)) | |
| [ "$count" -ge "$NUM_SAMPLES" ] && break | |
| done < <(random_stream) | |
| while IFS=$'\t' read -r occupation email id; do | |
| users_json+=$( | |
| printf '{"name":"Prolific ID: %s","email":"%s","position":"%s","employer":"n/a","area_of_clinical_ex":"n/a"},' \ | |
| "$id" "$email" "$occupation" | |
| ) | |
| count=$((count+1)) | |
| [ "$count" -ge "$NUM_SAMPLES" ] && break | |
| done < <(random_stream | awk -F'|' '{print $1"\t"$2"\t"$3}') |
| API_URL="api_url_here" | ||
| API_KEY="api_key_here |
Copilot
AI
Jun 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hardcoding placeholder values can cause confusion. Instead, read from the environment and validate, e.g.: : "${API_URL:?Please set API_URL}" and remove the default assignment.
| API_URL="api_url_here" | |
| API_KEY="api_key_here | |
| : "${API_URL:?Error: Please set API_URL environment variable}" | |
| : "${API_KEY:?Error: Please set API_KEY environment variable}" |
No description provided.