Duplicate usernames in current DB (get usernames and their uuids):
- SELECT DISTINCT mw.uuid, mw.username FROM identities p JOIN identities mw WHERE mw.source = "mediawiki" AND p.source = "phabricator" AND mw.uuid != p.uuid AND mw.username = p.username AND mw.username IS NOT NULL AND p.username IS NOT NULL ORDER BY mw.username;
#!/bin/bash mwusername=( username1 username2 username3 from sql query above) uuid=( uuid1 uuid2 uuid3 from sql query above) arrayLength=${#mwusername[@]} # Output "jq: error (at <stdin>:0): Cannot iterate over null (null)" means that the mwusername has no associated Phab account # Empty output means that the Phab username has no associated mw (but LDAP) account and hence cannot be queried by that for (( i=0; i<${arrayLength}; i++ )); do curl -s https://phabricator.wikimedia.org/api/user.mediawikiquery -d api.token=yourapitoken -d names[0]="${mwusername[$i]}" | jq '.result[] | .userName,.mediawiki_username' echo "https://wikimedia.biterg.io/identities/hatstall/${uuid[$i]}" sleep 10 done
Then clean up output.
Then if same name, merge (needs more thought how to do exactly)