Merge branch 'master' of ssh://forge.april.org:221/Chapril/mobilizon.chapril.org-tools

This commit is contained in:
tykayn 2020-11-26 17:43:20 +01:00 committed by root
commit 3cae67750e

View File

@ -30,6 +30,17 @@ source "/etc/mobilizon.chapril.org/mobilizonchaprilorg.conf"
IPV4_PATTERN="[0-9]{1,3}(\.[0-9]{1,3}){3}"
IPV6_PATTERN="[0-9a-f]{0,4}(:[0-9a-f]{0,4}){2,7}"
# TODO métriques à récupérer
# https://docs.joinmobilizon.org/contribute/graphql_api/
API_URL="https://mobilizon.chapril.org/api/"
# get statistics from the graphQL api of the website
json=$(curl -X POST \
-H "Content-Type: application/json" \
--data '{"query":"{\n statistics {\n numberOfUsers\n numberOfEvents\n numberOfLocalEvents\n numberOfComments\n numberOfLocalComments\n numberOfGroups\n numberOfLocalGroups\n numberOfInstanceFollowers\n numberOfInstanceFollowings\n }\n}\n"}' $API_URL)
echo $json;
#
help()
{
@ -73,9 +84,19 @@ generateHTTPReport()
echo
}
# display the value of a key in the json fetched with curl
function show
{
# to navigate to sub keys like data.statistics.my_key , we must use multiple -e extract options
local value=$(echo "$json" | jshon -e "data" -e "statistics" -e $1 -u)
printf " $key=$value"
}
#
generateSpecificReport()
{
local monthEnglish="$1"
local year="$2"
local yearMonth="$3"
@ -90,11 +111,19 @@ generateSpecificReport()
echo "Nombre d'ipv6 utilisatrices du service = $ipv6UserCount"
echo "Nombre total d'ip utilisatrices du service = $((ipv4UserCount+ipv6UserCount))"
# TODO métriques à récupérer
# https://docs.joinmobilizon.org/contribute/graphql_api/
echo "Nombre de comptes utilisateurs"
echo "Nombre d'évènements passés"
echo "Nombre d'évènements à venir"
# echo "Nombre de comptes utilisateurs = "
show "numberOfEvents"
show "numberOfLocalEvents"
show "numberOfGroups"
show "numberOfLocalGroups"
show "numberOfComments"
show "numberOfLocalComments"
show "numberOfInstanceFollowers"
show "numberOfInstanceFollowings"
show "numberOfUsers"
# echo "Nombre d'évènements passés"
# echo "Nombre d'évènements à venir"
echo
}