server/qa-fill-todo.sh

28 lines
966 B
Bash
Executable File

#!/bin/sh
NB_THEMES_TODO=3
MIN_LVL_TODO=1
MAX_LVL_TODO=3
MIN_EXO_TODO=$(($MIN_LVL_TODO - 1))
MAX_EXO_TODO=$(($MAX_LVL_TODO - 1))
curl -s http://127.0.0.1:8081/api/teams/ | jq -r '.[] | [(.id | tostring), " ", .name] | add' | while read TEAMID TEAMSTR
do
if echo $TEAMSTR | grep "FIC Groupe" > /dev/null 2> /dev/null
then
GRPFIC=$(echo $TEAMSTR | sed -r 's/FIC Groupe //')
THEMES_TO_TESTS=$(curl -s http://127.0.0.1:8081/api/themes | jq -r '.[] | [(.id | tostring), " ", (.path | split("-") | .[0])] | add' | grep -v " $GRPFIC" | shuf | head -n $NB_THEMES_TODO | cut -d " " -f 1 | xargs | sed 's/^/"/;s/ /","/g;s/$/"/')
curl -s http://127.0.0.1:8081/api/themes.json | jq -r '.['$THEMES_TO_TESTS'] | .exercices | keys | .['$MIN_EXO_TODO:$MAX_EXO_TODO'] | .[]' | while read EXID
do
#curl -X POST -d @- -H "X-FIC-Team: nemunaire" http://127.0.0.1:8083/api/qa_work.json <<EOF
cat <<EOF
{"id_team": $TEAMID, "id_exercice": $EXID}
EOF
done
fi
done