Commit ceea3006 authored by Kevin Yung's avatar Kevin Yung
Browse files

Finalisation des tests, avec commentaires

parent ce500bcd
.result | sort_by(.lastSeenAt, .id) | reverse [] | ("<li><a href='" + @uri "https://lns.campusiot.imag.fr/#/organizations/\(.organizationID)/gateways/\(.id)" + "'>" + .id + "</a>: " + .name + " - (org " + .organizationID + ") - " + .lastSeenAt + "</li>" )
This diff is collapsed.
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
TODAY="2021-03-02" TODAY="2021-03-02"
#On stock les ids des gateways d'aujourd'hui
ids=$(jq --raw-output ".result[] | .id" test_json1.json) ids=$(jq --raw-output ".result[] | .id" test_json1.json)
id=() id=()
i=0 i=0
...@@ -10,10 +11,11 @@ do ...@@ -10,10 +11,11 @@ do
id[$i]=$ID id[$i]=$ID
i=$((i+1)) i=$((i+1))
done done
#On stock les dates de dernière activité des gateways d'aujourd'hui
dates=$(jq --raw-output ".result[] | .lastSeenAt" test_json1.json) dates=$(jq --raw-output ".result[] | .lastSeenAt" test_json1.json)
date=() date=()
date=($dates) date=($dates)
state=() state=()
full_date==() full_date==()
d=() d=()
...@@ -34,6 +36,8 @@ do ...@@ -34,6 +36,8 @@ do
done done
#On stock les states des gateways d'aujourd'hui dans un tableau en regardant la date
#de dernière activité des gateways
for (( i=0; i<${#d[@]}; i++ )) for (( i=0; i<${#d[@]}; i++ ))
do do
if [[ "${d[$i]}" == "$TODAY" ]] if [[ "${d[$i]}" == "$TODAY" ]]
...@@ -44,8 +48,7 @@ do ...@@ -44,8 +48,7 @@ do
fi fi
done done
#On stock les ids des gateways d'hier
ids_2=$(jq --raw-output ".result[] | .id" test_json2.json) ids_2=$(jq --raw-output ".result[] | .id" test_json2.json)
id_2=() id_2=()
i=0 i=0
...@@ -55,6 +58,7 @@ do ...@@ -55,6 +58,7 @@ do
i=$((i+1)) i=$((i+1))
done done
#On stock les states des gateways d'hier
full_state=$(jq --raw-output ".result[] | .lastState" test_json2.json) full_state=$(jq --raw-output ".result[] | .lastState" test_json2.json)
states_2=() states_2=()
j=0 j=0
...@@ -64,6 +68,8 @@ do ...@@ -64,6 +68,8 @@ do
j=$((j+1)) j=$((j+1))
done done
#On compare les states des gateways d'aujourd'hui et hier
for (( i=0; i<${#id[@]}; i++ )) for (( i=0; i<${#id[@]}; i++ ))
do do
for (( j=0; j<${#id_2[@]}; j++ )) for (( j=0; j<${#id_2[@]}; j++ ))
...@@ -78,6 +84,32 @@ do ...@@ -78,6 +84,32 @@ do
done done
done done
#On met à jour les states des gateways pour le prochain jour
echo "{
\"totalCount\": \"${#id[@]}\",
\"result\": [" > test.txt
for (( i=0; i<$((${#id[@]}-1)); i++ ))
do
echo " {
\"id\": \"${id[$i]}\",
\"lastState\": \"${state[$i]}\"
}," >> test.txt
done
echo " {
\"id\": \"${id[$((${#id[@]}-1))]}\",
\"lastState\": \"${state[$((${#id[@]}-1))]}\"
}
]
}" >> test.txt
#jq --raw-output -f gateways_to_html.jq test_json1.json | grep "0000024b0805031a" #jq --raw-output -f gateways_to_html.jq test_json1.json | grep "0000024b0805031a"
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
}, },
{ {
"id": "0080e1ffff011234", "id": "0080e1ffff011234",
"lastState": "passive" "lastState": "active"
}, },
{ {
"id": "0080e1ffff0153d7", "id": "0080e1ffff0153d7",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment