g1-stats/transform_json.sh

23 lines
817 B
Bash
Executable File

#!/bin/bash
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
if [[ -e $SCRIPTPATH/.env ]]; then source $SCRIPTPATH/.env; else echo "Veuillez créer votre fichier .env inspiré de .env.example" && exit 1; fi
rWallets=$(cat $WEBPATH/history/index_*.html | grep -E "Date:|Reçus simples wallets|Reçus simples portefeuille" | awk -F '<b>' '{ print $2 }' | awk '{ print $1 }' | tr -d '.' | tr ',' '.')
j=0
for i in $rWallets; do
if [[ $j == 0 ]]; then
dateN=$i
cp tpl/graph.json rWallets-$i.json
sed -i s/_DATE/$i/g rWallets-$i.json
j=1
else
result+=$(sed s/_RWALLET/$i/g rWallets-$dateN.json)
rm rWallets-$dateN.json
j=0
fi
done
sed "s/_JSONDATA/$result/g" tpl/graph.html > $WEBPATH/graph.html