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