Improve explorer; Add jq file for cumulate nbrMembres

This commit is contained in:
poka 2020-09-22 04:36:33 +02:00
parent 62a30b0260
commit b74036c39d
3 changed files with 17 additions and 5 deletions

View File

@ -1,9 +1,10 @@
#!/bin/bash
dateRange=$2
jsonFile="db/daily.json"
dateRange=$2
[[ -z $dateRange ]] && dateRange=$(jq -r '.[].date' $jsonFile | tail -n1)
lineNbr=$(grep -n "$dateRange" $jsonFile | cut -d : -f 1)
[[ -z $lineNbr ]] && echo "La date $dateRange n'existe pas en blockchain" && exit 1
[[ -z $lineNbr ]] && echo "La date $dateRange n'existe pas en cache G1Stats" && exit 1
cumulate() {
lineNbr=$(($lineNbr+7))
@ -42,4 +43,8 @@ day() {
jq . <<<"$jsonDated"
}
$1
mass() {
jq -f lib/sumNbrMembers.jq $jsonFile | jq '.UD*.nbrMembers' | awk '{ SUM += $1} END { printf "%.2f", SUM }'; echo
}
$1

View File

@ -21,6 +21,8 @@ addMembers() {
done
[[ -d $tmpSplit ]] && rm -r $tmpSplit || exit 1
popd >/dev/null
echo "$wallets" > tata
}
web() {
@ -99,8 +101,7 @@ sumSoldes() {
soldeM=$(echo $soldeMBrut | sed ':a;s/\B[0-9]\{3\}\>/ &/;ta')
### Calcul de la masse monétaire et du pourcentage de Ḡ1 sur les simples portefeuilles ###
monetaryMass=$(curl -s ${DUNITER}/blockchain/current | jq .monetaryMass)
monetaryMassBrut=$(echo "scale=2; ($monetaryMass/100)/1" | bc)
monetaryMassBrut=$(curl -s ${DUNITER}/blockchain/current | jq .monetaryMass | xargs -i echo "scale=2; ({}/100)/1" | bc)
monetaryMass=$(echo "$monetaryMassBrut" | tr . , | sed ':a;s/\B[0-9]\{3\}\>/ &/;ta')
pourcentSimpleWallet=$(echo "$soldeWBrut*100/$monetaryMassBrut/1" | bc -l | xargs printf %.1f)

6
lib/sumNbrMembers.jq Normal file
View File

@ -0,0 +1,6 @@
def accumulates(f):
foreach .[] as $row
(0;
. + ($row | f) ;
. as $x | $row | (f = $x));
accumulates(.nbrMembers)