Find followers of a Drupal.org issue
It’s been almost 10 years since Drupal.org introduced support for following issues without having to leave a comment. The number of people following an issue is shown in the issue search and on the issue itself.
But nowhere in the UI can you see who is following an issue. (The issue discussing this hasn’t seen any movement in 7 years).
Thankfully the Drupal.org API does expose this information. Until the UI does, here is a short shell script to parse out this information:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Remove query string and fragment identifier, then remove | |
# everything before the final slash. | |
nid=$(echo $1 | sed 's/[#?].*//' | sed 's/.*\///g') | |
result=$(eval "curl -s https://www.drupal.org/api-d7/node/$nid.json") | |
# Output the count of followers. | |
count=$(echo $result | jq '.flag_project_issue_follow_user | length') | |
echo "$count followers:" | |
printf "\n" | |
# Find the URI for each follower. | |
follower_uris=$(echo $result | jq '.flag_project_issue_follow_user[].uri') | |
while IFS= read -r line ; do | |
# Insert ".json" before the closing quote. | |
url=$(echo "$line" | sed 's/"$/.json"/') | |
# Find the follower's name and strip the wrapping quotes. | |
eval "curl -s $url" | jq '.name' | sed 's/"//g' | |
done < <(printf '%s\n' "$follower_uris") |
Note that the script requires jq.
Any feedback on my functional but unpolished shell scripting skills is welcome.
Have something to say about my post? Feel free to reply to me here.