Fix json format

This commit is contained in:
poka 2021-03-30 19:11:05 +02:00
parent 6406abc24d
commit b8db6bc258
1 changed files with 11 additions and 4 deletions

View File

@ -8,7 +8,7 @@ source $GPATH/.env
SOURCE_MBR="https://g1-stats.axiom-team.fr/data/wallets-g1-membres.txt"
SOURCE_LARF="https://g1-stats.axiom-team.fr/data/wallets-g1-simple.txt"
FILE="/tmp/geoloc-members.json"
FINAL_LOCATION="$WEBPATH/data"
FINAL_LOCATION="$WEBPATH/data/geoloc-members.json"
if [[ -f /home/axiom/apps/g1-stats/data/wallets-g1-membres.txt ]]; then
DATA_MBR=$(cat /home/axiom/apps/g1-stats/data/wallets-g1-membres.txt)
@ -24,6 +24,9 @@ fi
echo "[" > $FILE
ii=0
jj=0
for i in $DATA_MBR; do
result=$(jaklis get -p $i)
geoPoint=$(echo "$result" | jq .geoPoint 2>/dev/null)
@ -32,8 +35,10 @@ for i in $DATA_MBR; do
continue
else
isMbr='"isMember": true,'
resultWithMbr=$(echo -e "$result" | sed "s/\"geoPoint\": {/$isMbr\n \"geoPoint\": {/g")
resultWithMbr=$(echo "$result" | sed "s/\"geoPoint\": {/$isMbr \"geoPoint\": {/g")
echo "$resultWithMbr," >> $FILE
((ii++))
[[ $ii > 10 ]] && break;
fi
done
@ -45,8 +50,10 @@ for i in $DATA_LARF; do
continue
else
isMbr='"isMember": false,'
resultWithMbr=$(echo -e "$result" | sed "s/\"geoPoint\": {/$isMbr\n \"geoPoint\": {/g")
resultWithMbr=$(echo "$result" | sed "s/\"geoPoint\": {/$isMbr \"geoPoint\": {/g")
echo "$resultWithMbr," >> $FILE
((jj++))
[[ $jj > 10 ]] && break;
fi
done
@ -54,5 +61,5 @@ sed -i '$ d' $FILE
echo "}" >> $FILE
echo "]" >> $FILE
mv $FILE $FINAL_LOCATION
[[ -f $FINAL_LOCATION ]] && jq . <<<$FILE > $FINAL_LOCATION