From 92ae59a3615f9e5057271042ea8cde11fffcaa3d Mon Sep 17 00:00:00 2001 From: poka Date: Tue, 29 Mar 2022 18:25:50 +0200 Subject: [PATCH] Add timestamp to json; change JSON format to do it. --- scripts/geoloc-members-json.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/scripts/geoloc-members-json.sh b/scripts/geoloc-members-json.sh index 25eea51..124f013 100755 --- a/scripts/geoloc-members-json.sh +++ b/scripts/geoloc-members-json.sh @@ -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