diff --git a/utils/c4s_stats.sh b/utils/c4s_stats.sh index 58fb063..5107d82 100755 --- a/utils/c4s_stats.sh +++ b/utils/c4s_stats.sh @@ -1,34 +1,64 @@ #!/bin/bash function req { ssh c4science-db01 "mysql -B -e \"$@\" phabricator_user" 2> /dev/null #ssh c4science-db01 "mysql -B -e \"$@\" phabricator_user" } function count { echo -e "$@" | awk '{print $2}' } total=$(count $(req "select count(id) from user;")) shib=$(count $(req "select count(id) from user_externalaccount where accountType='shibboleth' and userPHID is not NULL;")) ext=$(count $(req "select count(id) from user_externalaccount where userPHID not in (select userPHID from user_externalaccount where accountType='shibboleth' and userPHID is not NULL);")) bot=$(count $(req "select count(id) from user where phid not in (select userPHID from user_externalaccount where userPHID is not NULL);")) SQL="select right(accountID, length(accountID)-INSTR(accountID, '@')) as domain, count(*) as count from user_externalaccount where accountType='shibboleth' and userPHID is not NULL group by domain" stats=$(req $SQL) epfl=$(count $(echo -e "$stats" | grep epfl.ch)) other=$(($(echo -e "$stats" | awk '{SUM += $2} END{print SUM}') - $epfl)) +echo +echo 'USERS' echo echo "Total: $total" echo -e "\t UNI: $shib" echo -e "\t External: $ext" echo -e "\t Bot: $bot" echo echo "UNI:" echo -e "\t EPFL: $epfl" echo -e "\t Other: $other" echo echo "Control" echo -e "\t Total: $total=$(($shib + $ext + $bot))" echo -e "\t UNI: $shib=$(($epfl + $other))" + +function req_repo { + ssh c4science-db01 "mysql -B -e \"$@\" phabricator_repository" 2> /dev/null +} + +total=$(count $(req_repo "select count(id) from repository;")) +git=$(count $(req_repo "select count(id) from repository where versionControlSystem='git';")) +svn=$(count $(req_repo "select count(id) from repository where versionControlSystem='svn';")) +hg=$(count $(req_repo "select count(id) from repository where versionControlSystem='hg';")) + +echo +echo 'REPOSITORIES' +echo +echo "Total: $total" +echo -e "\t GIT: $git" +echo -e "\t SVN: $svn" +echo -e "\t Hg: $hg" + +function req_proj { + ssh c4science-db01 "mysql -B -e \"$@\" phabricator_project" 2> /dev/null +} + +total=$(count $(req_proj "select count(id) from project;")) + +echo +echo 'PROJECTS' +echo +echo "Total: $total"