Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit af917337 authored by Antoine Blanquet's avatar Antoine Blanquet
Browse files

bug fixed with kevin yung (momentjs)

parent e132ff1b
......@@ -6,7 +6,6 @@ process.argv.shift(); // skip path of js file
argv = process.argv.join(" ") // parse to keep only the string
function f(lastSeenAt) {
console.log(lastSeenAt);
lastSeenAt = new Date(lastSeenAt);
return moment(lastSeenAt).fromNow();
}
......
{
"totalCount": "22",
"result": [
{
"id": "e24f43fffe44d05f",
"lastState": "passive"
},
{
"id": "e24f43fffe44cf7c",
"lastState": "active"
},
{
"id": "70b3d58ff1012b89",
"lastState": "active"
},
{
"id": "e24f43fffe44d1ca",
"lastState": "passive"
},
{
"id": "a81758fffe032273",
"lastState": "active"
},
{
"id": "0004a30b00241873",
"lastState": "passive"
},
{
"id": "0004a30b001ff623",
"lastState": "passive"
},
{
"id": "1111111111111111",
"lastState": "passive"
},
{
"id": "0025ca0a000004d2",
"lastState": "active"
},
{
"id": "244e7b0002000814",
"lastState": "active"
},
{
"id": "0004a30b00237b0c",
"lastState": "passive"
},
{
"id": "e24f43fffe44d342",
"lastState": "passive"
},
{
"id": "e24f43fffe44d333",
"lastState": "passive"
},
{
"id": "e24f43fffe44d13a",
"lastState": "passive"
},
{
"id": "e24f43fffe44cf48",
"lastState": "passive"
},
{
"id": "0025ca0a000004db",
"lastState": "active"
},
{
"id": "e24f43fffe44c2c8",
"lastState": "passive"
},
{
"id": "70b3d58ff1004297",
"lastState": "active"
},
{
"id": "aabbccddeeff0011",
"lastState": "passive"
},
{
"id": "e24f43fffe44cff3",
"lastState": "passive"
},
{
"id": "e24f43fffe44c2cb",
"lastState": "passive"
},
{
"id": "e24f43fffe44cf96",
"lastState": "active"
}
]
}
{
"totalCount": "22",
"result": [
{
"id": "0000024b0805031a",
"lastState": "active"
},
{
"id": "7276ff0039030716",
"lastState": "active"
},
{
"id": "7276ff0039030724",
"lastState": "active"
},
{
"id": "7276ff0039030871",
"lastState": "active"
},
{
"id": "0080e1ffff0153f1",
"lastState": "passive"
},
{
"id": "0080e1ffff011234",
"lastState": "passive"
},
{
"id": "0080e1ffff0153d7",
"lastState": "passive"
},
{
"id": "080027ffff052e4a",
"lastState": "passive"
},
{
"id": "0080e1ffff014fe1",
"lastState": "passive"
},
{
"id": "0080e1ffff014feb",
"lastState": "passive"
},
{
"id": "0080e1ffff01523c",
"lastState": "passive"
},
{
"id": "0080e1ffff01523e",
"lastState": "passive"
},
{
"id": "0080e1ffff015240",
"lastState": "passive"
},
{
"id": "0080e1ffff015241",
"lastState": "passive"
},
{
"id": "0080e1ffff015242",
"lastState": "passive"
},
{
"id": "0080e1ffff015244",
"lastState": "passive"
},
{
"id": "0080e1ffff015252",
"lastState": "passive"
},
{
"id": "0080e1ffff015253",
"lastState": "passive"
},
{
"id": "0080e1ffff015256",
"lastState": "passive"
},
{
"id": "0080e1ffff015257",
"lastState": "passive"
},
{
"id": "0080e1ffff01525e",
"lastState": "passive"
},
{
"id": "0080e1ffff015abf",
"lastState": "passive"
}
]
}
......@@ -47,7 +47,7 @@ done
#On stock les ids des devices d'hier
ids_2=$(jq --raw-output ".result[] | .id" ${DATA_DEV_FOLDER}last_devices_states.json)
ids_2=$(jq --raw-output ".result[] | .id" ${DATA_DEV_FOLDER}.last_devices_states.json)
id_2=()
i=0
for ID in $ids_2
......@@ -57,7 +57,7 @@ do
done
#On stock les states des devices d'hier
full_state=$(jq --raw-output ".result[] | .lastState" ${DATA_DEV_FOLDER}last_devices_states.json)
full_state=$(jq --raw-output ".result[] | .lastState" ${DATA_DEV_FOLDER}.last_devices_states.json)
states_2=()
j=0
for s in $full_state
......@@ -90,25 +90,24 @@ do
done
if [[ ${date[$i]} != "null" ]]
then
echo "on change la date ici"
# tmp=$(grep ${id[$i]} < .devices.html)
# dateFromNow=$(node change_date_momentjs.js ${date[$i]})
# replacement=${tmp/${date[$i]}/"$dateFromNow"}
# sed -i "/${id[$i]}/c $replacement" .devices.html
tmp=$(grep ${id[$i]} < .devices.html)
dateFromNow=$(node change_date_momentjs.js ${date[$i]})
replacement=${tmp/${date[$i]}/"$dateFromNow"}
sed -i "/${id[$i]}/c $replacement" .devices.html
fi
done
#On met à jour les states des devices pour le prochain jour
echo "{
\"totalCount\": \"${#id[@]}\",
\"result\": [" > ${DATA_DEV_FOLDER}last_devices_states.json
\"result\": [" > ${DATA_DEV_FOLDER}.last_devices_states.json
for (( i=0; i<$((${#id[@]}-1)); i++ ))
do
echo " {
\"id\": \"${id[$i]}\",
\"lastState\": \"${state[$i]}\"
}," >> ${DATA_DEV_FOLDER}last_devices_states.json
}," >> ${DATA_DEV_FOLDER}.last_devices_states.json
done
echo " {
......@@ -116,4 +115,4 @@ echo " {
\"lastState\": \"${state[$((${#id[@]}-1))]}\"
}
]
}" >> ${DATA_DEV_FOLDER}last_devices_states.json
\ No newline at end of file
}" >> ${DATA_DEV_FOLDER}.last_devices_states.json
\ No newline at end of file
......@@ -46,7 +46,7 @@ do
done
#We store yesterday gateways ids
ids_2=$(jq --raw-output ".result[] | .id" ${DATA_GAT_FOLDER}last_gateways_states.json)
ids_2=$(jq --raw-output ".result[] | .id" ${DATA_GAT_FOLDER}.last_gateways_states.json)
id_2=()
i=0
for ID in $ids_2
......@@ -56,7 +56,7 @@ do
done
#We store yesterday gateways states
full_state=$(jq --raw-output ".result[] | .lastState" ${DATA_GAT_FOLDER}last_gateways_states.json)
full_state=$(jq --raw-output ".result[] | .lastState" ${DATA_GAT_FOLDER}.last_gateways_states.json)
states_2=()
j=0
for s in $full_state
......@@ -89,25 +89,24 @@ do
done
if [[ ${date[$i]} != "null" ]]
then
echo "on change la date ici"
# tmp=$(grep ${id[$i]} < .gateways.html)
# dateFromNow=$(node change_date_momentjs.js ${date[$i]})
# replacement=${tmp/${date[$i]}/"$dateFromNow"}
# sed -i "/${id[$i]}/c $replacement" .gateways.html
tmp=$(grep ${id[$i]} < .gateways.html)
dateFromNow=$(node change_date_momentjs.js ${date[$i]})
replacement=${tmp/${date[$i]}/"$dateFromNow"}
sed -i "/${id[$i]}/c $replacement" .gateways.html
fi
done
#We update gateways state for the next day
echo "{
\"totalCount\": \"${#id[@]}\",
\"result\": [" > ${DATA_GAT_FOLDER}last_gateways_states.json
\"result\": [" > ${DATA_GAT_FOLDER}.last_gateways_states.json
for (( i=0; i<$((${#id[@]}-1)); i++ ))
do
echo " {
\"id\": \"${id[$i]}\",
\"lastState\": \"${state[$i]}\"
}," >> ${DATA_GAT_FOLDER}last_gateways_states.json
}," >> ${DATA_GAT_FOLDER}.last_gateways_states.json
done
echo " {
......@@ -115,4 +114,4 @@ echo " {
\"lastState\": \"${state[$((${#id[@]}-1))]}\"
}
]
}" >> ${DATA_GAT_FOLDER}last_gateways_states.json
\ No newline at end of file
}" >> ${DATA_GAT_FOLDER}.last_gateways_states.json
\ No newline at end of file
Markdown is supported
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