Add timestamp to json; change JSON format to do it.

This commit is contained in:
poka 2022-03-29 18:25:50 +02:00
parent e671679932
commit 92ae59a361
1 changed files with 14 additions and 6 deletions

View File

@ -7,14 +7,13 @@ source $GPATH/.env
FILE="/tmp/geoloc-members.json"
FINAL_LOCATION="$WEBPATH/data/geoloc-members.json"
FINAL_LOCATION_ALT="$WEBPATH/data/geoloc-members-alt.json"
DATA_MBR=$($JAKLIS listWallets --brut --mbr)
DATA_NONMBR=$($JAKLIS listWallets --brut --non_mbr)
DATA_LARF=$($JAKLIS listWallets --brut --larf)
echo "$DATA_LARF" > /tmp/tatata
echo "[" > $FILE
echo "[{\"wallets\":[" > $FILE
oldIFS=$IFS;
IFS=$'\n';
@ -34,6 +33,8 @@ for i in $DATA_MBR; do
resultWithMbr=$(echo "$result" | sed "s/\"geoPoint\": {/$userIdFormat $isMbr \"geoPoint\": {/g")
echo "$resultWithMbr," >> $FILE
fi
[[ $DEBUG ]] && echo "$j - $i"
((j++))
done
IFS=$'\n'
@ -52,6 +53,8 @@ for i in $DATA_NONMBR; do
resultWithMbr=$(echo "$result" | sed "s/\"geoPoint\": {/$userIdFormat $isMbr \"geoPoint\": {/g")
echo "$resultWithMbr," >> $FILE
fi
[[ $DEBUG ]] && echo "$j - $i"
((j++))
done
@ -66,17 +69,22 @@ for i in $DATA_LARF; do
resultWithMbr=$(echo "$result" | sed "s/\"geoPoint\": {/$isMbr \"geoPoint\": {/g")
echo "$resultWithMbr," >> $FILE
fi
[[ $DEBUG ]] && echo "$j - $i"
((j++))
done
nowD=$(date +"%s")
sed -i '$ d' $FILE
echo "}" >> $FILE
echo "]" >> $FILE
echo "}]},{" >> $FILE
echo "\"time\": $nowD" >> $FILE
echo "}]" >> $FILE
finalResult=$(cat $FILE | jq .)
RESULT=$?
if [ $RESULT -eq 0 ]; then
echo "$finalResult" > $FINAL_LOCATION
echo "$finalResult" > $FINAL_LOCATION_ALT
else
echo "Failed" >> $FILE
fi