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

Continuation sur les tests de comparaison de json (avec changement d'implémentation

parent 79bf7193
{"jwt":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJjaGlycHN0YWNrLWFwcGxpY2F0aW9uLXNlcnZlciIsImV4cCI6MTYxNDE3NDM0NSwiaXNzIjoiY2hpcnBzdGFjay1hcHBsaWNhdGlvbi1zZXJ2ZXIiLCJuYmYiOjE2MTQwODc5NDUsInN1YiI6InVzZXIiLCJ1c2VybmFtZSI6IkNoaXJwc3RhY2tNb25pdG9yaW5nIn0.ODwUrVuJXCWKd4IWf_AMR_INWvU33bczGN9UvZuHSws"}
\ No newline at end of file
{"jwt":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJjaGlycHN0YWNrLWFwcGxpY2F0aW9uLXNlcnZlciIsImV4cCI6MTYxNDc3NzYwNSwiaXNzIjoiY2hpcnBzdGFjay1hcHBsaWNhdGlvbi1zZXJ2ZXIiLCJuYmYiOjE2MTQ2OTEyMDUsInN1YiI6InVzZXIiLCJ1c2VybmFtZSI6IkNoaXJwc3RhY2tNb25pdG9yaW5nIn0.k5qXExf1DgeFOGbQQUhOcJM2IowReWXBRftB8PUejZs"}
\ No newline at end of file
.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.
TODAY=$(date +"%Y-%m-%d")
#jq --raw-output -f gateways_to_html.jq .gateways.json | grep $TODAY
#!/bin/bash
json1=$(jq -c ".result | sort_by(.lastSeenAt, .id) | reverse []" test_json1.json)
#json2=$(jq --raw-output ".result | sort_by(.lastSeenAt, .id) | reverse [] | (.id)" test_json2.json)
d1=$(jq --raw-output ".result | sort_by(.lastSeenAt, .id) | reverse [] | (.lastSeenAt)" test_json1.json)
#echo $json1
jq -c ".result | sort_by(.lastSeenAt, .id) | reverse []" test_json1.json | while read i; do
echo $i
echo "---"
#test="2021-03-02T13:45:35.488962Z"
#t1=$(echo $test | tr "T" "\n")
#i=0
#t2=()
#for x in $t1
#do
# t2[i]=$x
# i=$((i+1))
#done
#for j1 in $json1
#echo ${t2[0]}
#if [[ ${t2[0]} = $TODAY ]]
#then
# echo "good"
#else
# echo "bad"
#fi
ids=$(jq --raw-output ".result[] | .id" test_json1.json)
id=()
i=0
for ID in $ids
do
id[$i]=$ID
#echo $id
i=$((i+1))
done
dates=$(jq --raw-output ".result[] | .lastSeenAt" test_json1.json)
date=()
j=0
for date in $dates
do
date[$j]=$date
j=$((j+1))
done
state=()
full_date=$(echo $date[$i] | tr "T" "\n")
x=0
d=()
for arg in $full_date
do
d[$x]=$arg
x=$((x+1))
done
for (( i=0; i<${#d[@]}; i++ ))
do
if [[ "${d[$i]}" == "$TODAY" ]]
then
state[$i]="active"
else
state[$i]="passive"
fi
done
ids_2=$(jq --raw-output ".result[] | .id" test_json2.json)
id_2=()
i=0
for ID in $ids_2
do
id_2[$i]=$ID
i=$((i+1))
done
full_state=$(jq --raw-output ".result[] | .lastState" test_json2.json)
states_2=()
j=0
for s in $full_state
do
state_2[$j]=$s
j=$((j+1))
done
for (( i=0; i<${#id[@]}; i++ ))
do
for (( j=0; j<${#id_2[@]}; j++ ))
do
if [[ "$id[$i]" == "$id_2[$j]" ]]
then
if [[ "$state[$i]" != "$state_2[$j]" ]]
then
echo ${id[$i]}+"CHANGEMENT"
fi
fi
done
done
#jq --raw-output -f gateways_to_html.jq test_json1.json | grep "0000024b0805031a"
#jq --raw-output ".result" test_json1.json
#jq -c ".result | sort_by(.lastSeenAt, .id) | reverse []" test_json1.json
#data=()
#objects=()
#id=()
#lastSeenAt=()
#i=0
#while read x
#do
#echo $j1
# data[$i]=$(echo $x | tr "," "\n")
# i=$((i+1))
#done <data.txt
#
#echo ${data[1]}
#echo "---"
#id=
#d1=$(jq --raw-output ".result | sort_by(.lastSeenAt, .id) | reverse [] | (.lastSeenAt)" test_json1.json |)
#echo $d1
done
\ No newline at end of file
#j=0
#cpt=$((${#data[@]}-1))
#for (( j=0; j<=$cpt; j++ ))
#do
# echo ${data[$j]}
# echo "---"
#
# #On récupère toutes les id dans le tableau id
# tmp=$(echo ${data[$j]} | tr [:space:] "_" | sed -e 's,"id":,\n,g')
# k=0
# for d in $tmp
# do
# objects[$k]=$d
# k=$((k+1))
# done
# tmp=$(echo ${objects[1]} | tr "_" "\n")
# for a in $tmp
# do
# id[$j]=$a
# break
# done
#
# #On récupère toutes les dates lastSeenAt dans un tableau (qui représentera le champ pour chaque id)
# #tmp
#done
#
#echo ${id[0]}
#echo ${id[1]}
#echo ${id[2]}
#echo ${id[3]}
##echo $test
##echo ${objects[1]}
\ No newline at end of file
{
"totalCount": "22",
"result": [
{
"id": "0000024b0805031a",
"name": "KER_107_POLYTECH",
"description": "LoRaServer Bridge",
"createdAt": "2020-08-12T12:49:20.213116Z",
"updatedAt": "2021-02-23T13:45:35.490898Z",
"firstSeenAt": "2020-11-30T14:33:34.452376Z",
"lastSeenAt": "2021-02-23T13:45:35.488962Z",
"organizationID": "6",
"networkServerID": "1",
"location": {
"latitude": 45.18434,
"longitude": 5.75338,
"altitude": 228,
"source": "UNKNOWN",
"accuracy": 0
}
},
{
"id": "7276ff0039030716",
"name": "KER_FEMTO_030716_P307",
"description": "Kerlink Wirnet iFemtoCell LoRaWAN Academy\nhttps://www.kerlink.fr/produit/wirnet-ifemtocell/\n\neth0 70:76:FF:02:07:7A\nwlan0 98:84:E3:BF:C7:D2\nIP 129.88.104.13\n",
"createdAt": "2020-10-09T10:37:41.392857Z",
"updatedAt": "2021-02-23T13:45:35.122199Z",
"firstSeenAt": "2021-01-30T14:06:43.965996Z",
"lastSeenAt": "2021-02-23T13:45:35.120423Z",
"organizationID": "6",
"networkServerID": "1",
"location": {
"latitude": 45.18439622301354,
"longitude": 5.753231048583985,
"altitude": 220,
"source": "UNKNOWN",
"accuracy": 0
}
},
{
"id": "7276ff0039030724",
"name": "KER_FEMTO_030724_P124",
"description": "Femto Kerlink - Semtech LoRa Academy\neth0 70:76:ff:02:07:88\nwlan0 F0:C7:7F:C9:DB:E7\nIP 129.88.104.12",
"createdAt": "2020-10-09T10:31:29.150691Z",
"updatedAt": "2021-02-23T13:45:35.782503Z",
"firstSeenAt": "2021-01-30T13:42:31.657870Z",
"lastSeenAt": "2021-02-23T13:45:35.780362Z",
"organizationID": "6",
"networkServerID": "1",
"location": {
"latitude": 45.18424498325449,
"longitude": 5.75310230255127,
"altitude": 220,
"source": "UNKNOWN",
"accuracy": 0
}
},
{
"id": "7276ff0039030871",
"name": "KER_FEMTO_030871_NP",
"description": "Kerlink Wirnet iFemtoCell LoRaWAN Academy https://www.kerlink.fr/produit/wirnet-ifemtocell/\n\neth0 70:76:FF:02:08:D4\nwlan0 98:84:E3:48:88:A2",
"createdAt": "2020-10-09T10:38:35.279330Z",
"updatedAt": "2021-02-23T13:45:40.803622Z",
"firstSeenAt": "2020-10-21T09:50:03.963231Z",
"lastSeenAt": "2021-02-23T13:45:40.801297Z",
"organizationID": "6",
"networkServerID": "1",
"location": {
"latitude": 45.19740133918228,
"longitude": 5.833740234375001,
"altitude": 0,
"source": "UNKNOWN",
"accuracy": 0
}
}
]
"totalCount": "24",
"result": [
{
"id": "0000024b0805031a",
"name": "KER_107_POLYTECH",
"description": "LoRaServer Bridge",
"createdAt": "2020-08-12T12:49:20.213116Z",
"updatedAt": "2021-03-02T13:20:05.351603Z",
"firstSeenAt": "2020-11-30T14:33:34.452376Z",
"lastSeenAt": "2021-03-02T13:20:05.349596Z",
"organizationID": "6",
"networkServerID": "1",
"location": {
"latitude": 45.18439,
"longitude": 5.75338,
"altitude": 237,
"source": "UNKNOWN",
"accuracy": 0
}
},
{
"id": "7276ff0039030716",
"name": "KER_FEMTO_030716_P307",
"description": "Kerlink Wirnet iFemtoCell LoRaWAN Academy\nhttps://www.kerlink.fr/produit/wirnet-ifemtocell/\n\neth0 70:76:FF:02:07:7A\nwlan0 98:84:E3:BF:C7:D2\nIP 129.88.104.13\n",
"createdAt": "2020-10-09T10:37:41.392857Z",
"updatedAt": "2021-03-02T13:20:04.423209Z",
"firstSeenAt": "2021-01-30T14:06:43.965996Z",
"lastSeenAt": "2021-03-02T13:20:04.421429Z",
"organizationID": "6",
"networkServerID": "1",
"location": {
"latitude": 45.18439622301354,
"longitude": 5.753231048583985,
"altitude": 220,
"source": "UNKNOWN",
"accuracy": 0
}
},
{
"id": "7276ff0039030724",
"name": "KER_FEMTO_030724_P124",
"description": "Femto Kerlink - Semtech LoRa Academy\neth0 70:76:ff:02:07:88\nwlan0 F0:C7:7F:C9:DB:E7\nIP 129.88.104.12",
"createdAt": "2020-10-09T10:31:29.150691Z",
"updatedAt": "2021-03-02T13:20:04.360040Z",
"firstSeenAt": "2021-01-30T13:42:31.657870Z",
"lastSeenAt": "2021-03-02T13:20:04.355108Z",
"organizationID": "6",
"networkServerID": "1",
"location": {
"latitude": 45.18424498325449,
"longitude": 5.75310230255127,
"altitude": 220,
"source": "UNKNOWN",
"accuracy": 0
}
},
{
"id": "7276ff0039030871",
"name": "KER_FEMTO_030871_NP",
"description": "Kerlink Wirnet iFemtoCell LoRaWAN Academy https://www.kerlink.fr/produit/wirnet-ifemtocell/\n\neth0 70:76:FF:02:08:D4\nwlan0 98:84:E3:48:88:A2",
"createdAt": "2020-10-09T10:38:35.279330Z",
"updatedAt": "2021-03-02T13:19:53.434134Z",
"firstSeenAt": "2020-10-21T09:50:03.963231Z",
"lastSeenAt": "2021-03-02T13:19:53.431742Z",
"organizationID": "6",
"networkServerID": "1",
"location": {
"latitude": 45.19740133918228,
"longitude": 5.833740234375001,
"altitude": 0,
"source": "UNKNOWN",
"accuracy": 0
}
},
{
"id": "0080e1ffff0153f1",
"name": "LRWAN2_0153F1_KEKA",
"description": "Enver KEKA/ Thibaud HUMBERT\nLocalisation : Proche CHAVANT (Enver) / Gare Grenoble (Alsace-Lorraine)\n",
"createdAt": "2021-02-23T16:42:29.229621Z",
"updatedAt": "2021-02-23T16:42:29.229621Z",
"firstSeenAt": null,
"lastSeenAt": null,
"organizationID": "5",
"networkServerID": "1",
"location": {
"latitude": 45.18545489007673,
"longitude": 5.731258188609468,
"altitude": 220,
"source": "UNKNOWN",
"accuracy": 0
}
},
{
"id": "0080e1ffff011234",
"name": "LRWAN2_1234",
"description": "Gateway de Machin et de Bidule",
"createdAt": "2020-10-12T14:18:03.422439Z",
"updatedAt": "2021-02-01T16:18:10.914756Z",
"firstSeenAt": null,
"lastSeenAt": null,
"organizationID": "5",
"networkServerID": "1",
"location": {
"latitude": 45.18433572715811,
"longitude": 5.753402709960938,
"altitude": 220,
"source": "UNKNOWN",
"accuracy": 0
}
},
{
"id": "0080e1ffff0153d7",
"name": "LRWAN2_153D7_SONZOGNI",
"description": "PM2M SONZOGNI",
"createdAt": "2021-02-23T16:33:58.381466Z",
"updatedAt": "2021-02-23T16:33:58.381466Z",
"firstSeenAt": null,
"lastSeenAt": null,
"organizationID": "5",
"networkServerID": "1",
"location": {
"latitude": 45.19280830183293,
"longitude": 5.731676768131312,
"altitude": 220,
"source": "UNKNOWN",
"accuracy": 0
}
},
{
"id": "080027ffff052e4a",
"name": "LRWAN2_2E4A",
"description": "Gateway LoRaWAN2 d'Alexandre SALMON et Thomas FRION",
"createdAt": "2020-10-25T15:26:33.683397Z",
"updatedAt": "2020-10-25T16:00:41.686580Z",
"firstSeenAt": null,
"lastSeenAt": null,
"organizationID": "5",
"networkServerID": "1",
"location": {
"latitude": 45.7226831,
"longitude": 5.9242678,
"altitude": 0,
"source": "UNKNOWN",
"accuracy": 0
}
},
{
"id": "0080e1ffff014fe1",
"name": "LRWAN2_4FE1_ROFFET_ROBERT",
"description": "Gateway Antoine ROFFET / Francois ROBERT\n",
"createdAt": "2020-10-26T09:13:50.490139Z",
"updatedAt": "2021-02-23T13:15:09.330789Z",
"firstSeenAt": null,
"lastSeenAt": null,
"organizationID": "5",
"networkServerID": "1",
"location": {
"latitude": 45.19050597326729,
"longitude": 5.753958682541712,
"altitude": 0,
"source": "UNKNOWN",
"accuracy": 0
}
},
{
"id": "0080e1ffff014feb",
"name": "LRWAN2_4FEB",
"description": "Gateway de Tristan MAINGUET",
"createdAt": "2020-12-06T13:05:02.270055Z",
"updatedAt": "2020-12-06T13:07:09.312290Z",
"firstSeenAt": null,
"lastSeenAt": null,
"organizationID": "5",
"networkServerID": "1",
"location": {
"latitude": 45.182740125763594,
"longitude": 5.730657577514649,
"altitude": 238,
"source": "UNKNOWN",
"accuracy": 0
}
},
{
"id": "0080e1ffff01523c",
"name": "LRWAN2_523C_THOMAS_HERVE",
"description": "Gateway de Xiang SUN et Haoran ZHANG",
"createdAt": "2020-12-06T13:16:36.678108Z",
"updatedAt": "2021-02-23T13:31:04.306534Z",
"firstSeenAt": null,
"lastSeenAt": null,
"organizationID": "5",
"networkServerID": "1",
"location": {
"latitude": 45.180297483446495,
"longitude": 5.744208097457887,
"altitude": 220,
"source": "UNKNOWN",
"accuracy": 0
}
},
{
"id": "0080e1ffff01523e",
"name": "LRWAN2_523E_VIVIANI",
"description": "Nicolas Viviani / Antoine Rotival\n",
"createdAt": "2021-01-08T08:29:03.697667Z",
"updatedAt": "2021-02-23T16:35:48.543451Z",
"firstSeenAt": null,
"lastSeenAt": null,
"organizationID": "5",
"networkServerID": "1",
"location": {
"latitude": 45.46783598133375,
"longitude": 4.474431487704341,
"altitude": 400,
"source": "UNKNOWN",
"accuracy": 0
}
},
{
"id": "0080e1ffff015240",
"name": "LRWAN2_5240",
"description": "Addr Ethernet 00 80 e1 01 52 40",
"createdAt": "2021-02-01T14:27:24.122997Z",
"updatedAt": "2021-02-01T14:27:24.122997Z",
"firstSeenAt": null,
"lastSeenAt": null,
"organizationID": "5",
"networkServerID": "1",
"location": {
"latitude": 45.18424498325449,
"longitude": 5.753574371337891,
"altitude": 220,
"source": "UNKNOWN",
"accuracy": 0
}
},
{
"id": "0080e1ffff015241",
"name": "LRWAN2_5241",
"description": "Gateway de florian jacquin ",
"createdAt": "2020-12-04T11:39:16.707206Z",
"updatedAt": "2020-12-04T11:39:16.707206Z",
"firstSeenAt": null,
"lastSeenAt": null,
"organizationID": "5",
"networkServerID": "1",
"location": {
"latitude": 0,
"longitude": 0,
"altitude": -2,
"source": "UNKNOWN",
"accuracy": 0
}
},
{
"id": "0080e1ffff015242",
"name": "LRWAN2_5242_HUMBERT",
"description": "Enver KEKA/ Thibaud HUMBERT\nLocalisation : Proche CHAVANT (Enver) / Gare Grenoble (Alsace-Lorraine)\n\n",
"createdAt": "2020-10-23T12:41:31.643182Z",
"updatedAt": "2021-02-23T16:40:38.076401Z",
"firstSeenAt": null,
"lastSeenAt": null,
"organizationID": "5",
"networkServerID": "1",
"location": {
"latitude": 45.189144947063426,
"longitude": 5.721686275766365,
"altitude": 0,
"source": "UNKNOWN",
"accuracy": 0
}
},
{
"id": "0080e1ffff015244",
"name": "LRWAN2_5244",
"description": "Gateway de Dima ASSI et Houda EL AJI pour le projet WSN de INFO5/Polytech Grenoble",
"createdAt": "2020-12-24T15:03:33.158942Z",
"updatedAt": "2020-12-24T18:47:07.168703Z",
"firstSeenAt": null,
"lastSeenAt": null,
"organizationID": "5",
"networkServerID": "1",
"location": {
"latitude": 45.18502008277258,
"longitude": 5.746954679489137,
"altitude": 0,
"source": "UNKNOWN",
"accuracy": 0
}
},
{
"id": "0080e1ffff015252",
"name": "LRWAN2_5252",
"description": "gateway de valentin blumert",
"createdAt": "2021-01-08T09:04:37.357613Z",
"updatedAt": "2021-01-08T09:04:37.357613Z",
"firstSeenAt": null,
"lastSeenAt": null,
"organizationID": "5",
"networkServerID": "1",
"location": {
"latitude": 45.18633205644303,
"longitude": 5.705938785678001,
"altitude": 220,
"source": "UNKNOWN",
"accuracy": 0
}
},
{
"id": "0080e1ffff015253",
"name": "LRWAN2_5253",
"description": "Gateway pour le projet IoT LIANG Jichen",
"createdAt": "2020-12-06T14:12:19.996004Z",
"updatedAt": "2021-01-08T10:07:07.385911Z",
"firstSeenAt": null,
"lastSeenAt": null,
"organizationID": "5",
"networkServerID": "1",
"location": {
"latitude": 45.1834546,
"longitude": 5.742217,
"altitude": 0,
"source": "UNKNOWN",
"accuracy": 0
}
},
{
"id": "0080e1ffff015256",
"name": "LRWAN2_5256",
"description": "Gateway Hugo RIBARD",
"createdAt": "2020-12-04T09:59:38.252876Z",
"updatedAt": "2020-12-04T09:59:38.252876Z",
"firstSeenAt": null,
"lastSeenAt": null,
"organizationID": "5",
"networkServerID": "1",
"location": {
"latitude": 45.188097,
"longitude": 5.7514791999999995,
"altitude": 220,
"source": "UNKNOWN",
"accuracy": 0
}
},
{
"id": "0080e1ffff015257",
"name": "LRWAN2_5257_ROFFET_ROBERT",
"description": "Gateway PM2M ROFFET ROBERT",
"createdAt": "2021-01-08T10:37:34.317049Z",
"updatedAt": "2021-02-23T13:28:57.531612Z",
"firstSeenAt": null,
"lastSeenAt": null,
"organizationID": "5",
"networkServerID": "1",
"location": {
"latitude": 45.18130329003343,
"longitude": 5.762570500373841,
"altitude": 0,
"source": "UNKNOWN",
"accuracy": 0
}
},
{
"id": "0080e1ffff01525e",
"name": "LRWAN2_525E",
"description": "Gateway de Flavien Mougeot et Gabriel Jaffres\n",
"createdAt": "2020-10-12T13:44:25.942475Z",