Skip to content

Conversation

@hoangsonww
Copy link
Member

No description provided.

@hoangsonww hoangsonww requested a review from Copilot June 19, 2025 01:15
@hoangsonww hoangsonww self-assigned this Jun 19, 2025
@hoangsonww hoangsonww added the enhancement New feature or request label Jun 19, 2025
@hoangsonww hoangsonww merged commit 78cb042 into main Jun 19, 2025
1 check passed
Copy link

Copilot AI left a 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.sh to 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_KEY assignment is missing a closing double quote, causing a syntax error. Add the closing ".
API_KEY="api_key_here

Comment on lines +51 to +59
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)
Copy link

Copilot AI Jun 19, 2025

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.

Suggested change
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}')

Copilot uses AI. Check for mistakes.
Comment on lines +18 to +19
API_URL="api_url_here"
API_KEY="api_key_here
Copy link

Copilot AI Jun 19, 2025

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.

Suggested change
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}"

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants