Get off nonconsumedUD and add monetaryMass

This commit is contained in:
poka 2019-11-08 06:48:13 +01:00
parent 0cf2540b64
commit da76528f96
2 changed files with 41 additions and 18 deletions

View File

@ -10,11 +10,11 @@ DUNITER="http://192.168.9.54:45000"
DUNITER2="https://g1.duniter.org"
DUNITER3="https://duniter.g1.1000i100.fr"
#indexhtml="/var/www/g1-stats/index-$day-$startTime-$id.html"
indexhtml="/var/www/g1-stats/index.html"
###
echo "######"
echo "$day à startTime"
[[ -z $(which jq) || -z $(which bc) ]] && apt update && apt install jq bc
echo "Initialisation ..."
outFile="/tmp/g1-stats-$day-$startTime_$id"
@ -97,7 +97,8 @@ web() {
sed -i "s/_pourcentMbrs/$pourcentMbrs/g" $indexhtml
sed -i "s/_pourcentWallets/$pourcentWallets/g" $indexhtml
# sed -i "s/_node/$DUNITER/g" $indexhtml
sed -i "s/_heure/$day_$startTime/g" $indexhtml
sed -i "s/_heure/$startTime/g" $indexhtml
sed -i "s/_day/$day/g" $indexhtml
sed -i "s/_txInSimple/$txInSimple/g" $indexhtml
sed -i "s/_txOutSimple/$txOutSimple/g" $indexhtml
sed -i "s/_soldeSimple/$soldeSimple/g" $indexhtml
@ -106,6 +107,7 @@ web() {
sed -i "s/_soldeMembers/$soldeMembers/g" $indexhtml
sed -i "s/_poucentSoldeMembers/$poucentSoldeMembers/g" $indexhtml
sed -i "s/_nonConsumedUDT/$nonConsumedUDT/g" $indexhtml
sed -i "s/_monetaryMass/$monetaryMass/g" $indexhtml
chown www-data:www-data $indexhtml 2>/dev/null
}
@ -138,14 +140,16 @@ solde=0
txInT=0
txOutT=0
nonConsumedUDT=0
nonConsumedUD=0
for i in $pubkeys; do
# echo $i
txInL=$(curl -s "http://g1.data.duniter.fr/g1/movement/_search?filter_path=hits.hits._source&size=10000&q=recipient:$i&pretty")
txOutL=$(curl -s "http://g1.data.duniter.fr/g1/movement/_search?filter_path=hits.hits._source&size=10000&q=issuer:$i&pretty")
[[ $1 == "mbr" ]] && nonConsumedUD=$(curl -s ${DUNITER}/ud/history/$i | jq '.history.history[].amount' | awk '{s+=$1} END {print s}') || nonConsumedUD=0
[[ $1 == "mbr" ]] && nonConsumedUDT=$(echo -e "scale=2; ($nonConsumedUD/100)+$nonConsumedUDT" | bc)
if [[ $1 == "mbr" ]]; then
nonConsumedUD=$(curl -s ${DUNITER}/ud/history/$i | jq '.history.history[].amount' | awk '{s+=$1} END {print s}') || nonConsumedUD=0
[[ -z $nonConsumedUD ]] && nonConsumedUD=0
nonConsumedUDT=$(echo -e "scale=2; ($nonConsumedUD/100)+$nonConsumedUDT" | bc)
fi
[[ $txInL != "{ }" ]] && txIn=$(echo "$txInL" | jq '.hits.hits[]._source.amount' | awk '{s+=$1} END {print s}') || txIn=0
[[ $txOutL != "{ }" ]] && txOut=$(echo "$txOutL" | jq '.hits.hits[]._source.amount' | awk '{s+=$1} END {print s}') || txOut=0
@ -174,7 +178,7 @@ echo -e "\n ---\n"
echo "Récupération du solde des membres..."
pubkeys=${MEMBERS[@]}
getSolde mbr
getSolde
txInMembers=$txInT
txOutMembers=$txOutT
soldeMembers=$solde
@ -183,14 +187,17 @@ echo -e "Envoyé membres:\t $txOutMembers"
echo -e "Soldes membres:\t $soldeMembers"
echo -e "Total DU non consumés:\t $nonConsumedUDT"
monetaryMass=$(curl -s ${DUNITER}/blockchain/current | jq .monetaryMass)
monetaryMass=$(echo -e "scale=2; ($monetaryMass/100)/1" | bc)
soldeWalletMembers=$(echo "scale=2; $soldeMembers+$soldeSimple" | bc)
poucentSoldeMembers=$(echo "scale=1; $soldeMembers*100/$soldeWalletMembers/1" | bc)
poucentSoldeMembers=$(echo "scale=1; $soldeMembers*100/$monetaryMass/1" | bc)
echo -e "\n ---\n"
echo -e "Solde Total:\t $soldeWalletMembers"
echo -e "Solde des membres (sans DU):\t $soldeWalletMembers"
echo -e "Masse Monétaire:\t $monetaryMass Ḡ1"
[[ $1 == "web" ]] && web
rm $outFile
echo "Heure de fin: $(date +'%T')"
echo "$day - Heure de fin: $(date +'%T')"

View File

@ -1,28 +1,44 @@
<html>
<meta charset="UTF-8">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<center><h1>La ḡ1 en quelques chiffres</h1></center>
<body>
heure: <b>_heure</b> <br>
noeud scanné: <b>http://192.168.9.54:45000</b> <br>
<center><h1>La Ḡ1 en quelques chiffres</h1></center>
<br>---<br>
<div id=mainbloc>
Date: <b>_day - _heure</b> <br>
Noeud scanné: <b>https://duniter-g1.p2p.legal</b> <br>
<br>---<br><br>
Nombre total de wallet: <b>_nbrTotalWallets</b> <br>
Nombre de membres: <b>_nbrMembers</b> (_pourcentMbrs%) <br>
Nombre de simple portefeuille: <b>_nbrSimpleWallets</b> (_pourcentWallets%) <br>
<br>---<br>
<br>---<br><br>
Reçus simples wallets: <b>_txInSimple</b><br>
Envoyé simples wallets: <b>_txOutSimple</b><br>
Soldes simples wallets: <b>_soldeSimple</b> (_poucentSoldeMembers%)<br>
<br>---<br>
<br>---<br><br>
Reçus membres: <b>_txInMembers</b><br>
Envoyé membres: <b>_txOutMembers</b><br>
Soldes membres: <b>_soldeMembers</b><br>
Total DU non consommés: <b>_nonConsumedUDT</b><br>
Masse monétaire: <b>_monetaryMass</b>
</div>
<br>
<center>
| <a href="/wallets-g1.txt">Liste de tous les wallets</a>
| <a href="/wallets-g1-membres.txt">Liste des wallets membres</a>
| <a href="/wallets-g1-simple.txt">Liste des simples portefeuilles</a> |
</center>
</body>
</html>