From d4990916b5cc02ec5f7939057c5d8aca7f851de4 Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Tue, 25 Jul 2023 09:21:11 +0200 Subject: [PATCH] qa: Update scripts --- qa-add-todo.sh | 24 ++++++++++++++++++++++++ qa-common.sh | 11 +++++++++++ qa-fill-todo.sh | 22 +++++++++------------- qa-fill-view-overview.sh | 20 ++++++++++++++++++++ qa-fill-view.sh | 12 +++++++----- qa-merge-db.sh | 12 ++++++------ 6 files changed, 77 insertions(+), 24 deletions(-) create mode 100755 qa-add-todo.sh create mode 100644 qa-common.sh create mode 100755 qa-fill-view-overview.sh diff --git a/qa-add-todo.sh b/qa-add-todo.sh new file mode 100755 index 00000000..15c2ff9d --- /dev/null +++ b/qa-add-todo.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +source qa-common.sh + +TEAMNUM=$1 +THEMETODO=$2 +MIN_EXO_TODO=$3 +[ $# -gt 3 ] && MAX_EXO_TODO=$4 || MAX_EXO_TODO=$MIN_EXO_TODO +MIN_EXO_TODO=$(($MIN_EXO_TODO - 1)) + +curl -s http://${HOST_FICADMIN}/api/teams | jq -r '.[] | [(.id | tostring), " ", .name] | add' | grep "${TEAM_PREFIX} ${TEAMNUM}" | while read TEAMID TEAMSTR +do + if echo $TEAMSTR | grep "${TEAM_PREFIX}" > /dev/null 2> /dev/null + then + GRPFIC=$(echo $TEAMSTR | sed -r "s/${TEAM_PREFIX} //") + + curl -s http://${HOST_FICADMIN}/api/themes.json | jq -r '.["'$THEMETODO'"] | .exercices['$MIN_EXO_TODO:$MAX_EXO_TODO'] | .[].id' | while read EXID + do + curl -X POST -d @- -H "X-FIC-Team: ${QA_ADMIN}" http://${HOST_FICQA}/api/qa_work.json < /dev/null 2> /dev/null + if echo $TEAMSTR | grep "${TEAM_PREFIX}" > /dev/null 2> /dev/null then - GRPFIC=$(echo $TEAMSTR | sed -r 's/FIC Groupe //') + GRPFIC=$(echo $TEAMSTR | sed -r "s/${TEAM_PREFIX} //") - 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/$/"/') + THEMES_TO_TESTS=$(curl -s http://${HOST_FICADMIN}/api/themes | jq -r '.[] | [(.id | tostring), " ", (.path | split("-") | .[0])] | add' | grep -v " grp$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 + curl -s http://${HOST_FICADMIN}/api/themes.json | jq -r '.['$THEMES_TO_TESTS'] | .exercices['$MIN_EXO_TODO:$MAX_EXO_TODO'] | .[].id' | while read EXID do - #curl -X POST -d @- -H "X-FIC-Team: nemunaire" http://127.0.0.1:8083/api/qa_work.json < /dev/null 2> /dev/null; then echo export TEAM_$TEAM=$ID | sed -r "s/${TEAM_PREFIX} //"; fi; done` + +# Add all themes and exercices to assistants +curl -s http://${HOST_FICADMIN}/api/themes | jq '.[].id' | while read tid +do + TEAM="TEAM_$(curl -s http://${HOST_FICADMIN}/api/themes/$tid | jq -r .path | sed -r 's/^[^0-9]*([0-9]+)-.*$/\1/')" + curl -s http://${HOST_FICADMIN}/api/themes/$tid/exercices | jq .[].id | while read ex + do + curl -X POST -d @- -H "X-FIC-Team: ${QA_ADMIN}" http://${HOST_FICQA}/api/qa_my_exercices.json < /dev/null 2> /dev/null; then echo TEAM_$TEAM=$ID | sed -r 's/FIC Groupe //'; fi; done` +`curl -s http://${HOST_FICADMIN}/api/teams | jq -r '.[] | [(.id | tostring), " ", .name] | add' | while read ID TEAM; do if echo $TEAM | grep "${TEAM_PREFIX}" > /dev/null 2> /dev/null; then echo export TEAM_$TEAM=$ID | sed -r "s/${TEAM_PREFIX} //"; fi; done` # Add their themes and exercices -curl -s http://127.0.0.1:8081/api/themes | jq '.[].id' | while read tid +curl -s http://${HOST_FICADMIN}/api/themes | jq '.[].id' | while read tid do - TEAM="TEAM_$(curl -s http://127.0.0.1:8081/api/themes/$tid | jq -r .path | sed -r 's/-.*$//')" - curl -s http://127.0.0.1:8081/api/themes/$tid/exercices | jq .[].id | while read ex + TEAM="TEAM_$(curl -s http://${HOST_FICADMIN}/api/themes/$tid | jq -r .path | sed -r 's/^[^0-9]*([0-9]+)-.*$/\1/')" + curl -s http://${HOST_FICADMIN}/api/themes/$tid/exercices | jq .[].id | while read ex do - curl -X POST -d @- -H "X-FIC-Team: nemunaire" http://127.0.0.1:8083/api/qa_my_exercices.json <&2 echo "Please give DB to read from as argument"; exit 1; } +source qa-common.sh + MYSQL_USER="${MYSQL_USER:-fic}" MYSQL_PASSWORD="${MYSQL_PASSWORD:-fic}" MYSQL_DATABASE="$1" -QA_ADMIN="${QA_ADMIN:-nemunaire@nemunai.re}" - -EXERCICES=$(curl -s -H "X-FIC-Team: ${QA_ADMIN}" http://127.0.0.1:8083/api/exercices/) -TEAMS=$(curl -s http://127.0.0.1:8081/api/teams/ | jq -r '.[].id' | while read IDTEAM; do curl -s http://127.0.0.1:8081/api/teams/$IDTEAM/associations | jq -r ".[] | {login: ., id_team: \"$IDTEAM\"}"; done) +EXERCICES=$(curl -s -H "X-FIC-Team: ${QA_ADMIN}" http://${HOST_FICQA}/api/exercices/) +TEAMS=$(curl -s http://${HOST_FICADMIN}/api/teams/ | jq -r '.[].id' | while read IDTEAM; do curl -s http://${HOST_FICADMIN}/api/teams/$IDTEAM/associations | jq -r ".[] | {login: ., id_team: \"$IDTEAM\"}"; done) echo "select Q.*, T.name, E.title from exercices_qa Q INNER JOIN exercices E ON E.id_exercice = Q.id_exercice INNER JOIN themes T ON T.id_theme = E.id_theme;" | mysql --skip-column-names -u "${MYSQL_USER}" --password="${MYSQL_PASSWORD}" "${MYSQL_DATABASE}" | tr '\t' '|' | while IFS='|' read IDQ IDEXERCICE IDTEAM REMOTE_USER SUBJECT CREATION STATE SOLVED CLOSED THEME EXERCICE_TITLE do @@ -30,7 +30,7 @@ $SUBJECT EOF ) - QA=$(curl -s -f -X POST -d @- "http://127.0.0.1:8081/api/qa/" < /dev/null + curl -s -f -X POST -d @- "http://${HOST_FICADMIN}/api/qa/$QAID/comments" < /dev/null { "id_team": $IDTEAM, "user": "$REMOTE_USER",