Compare commits

..

1 Commits

Author SHA1 Message Date
Jean-Jacques Brucker ef23a0a66d Partialy rewrite scripts/walletsBalance.sh:
* support both silkaj and jaklis
* add a field "position"
* add some id to have anchors for url, eg: .../wallets_balance.html#k2ny7YAdmzReQxAayyJZsyVYwYhVyax2thKcGknmQy5nQ
* add links payto://g1/..., cf. https://tools.ietf.org/html/rfc8905
2021-03-08 16:14:39 +01:00
21 changed files with 108 additions and 364 deletions

2
.gitignore vendored
View File

@ -6,5 +6,3 @@ debug.log
bk-debug.log
bk
.gitPushToMaster.sh
walletsBalance.log

View File

@ -65,4 +65,3 @@ Par exemple pour l'exécuter toutes les 3 heures:
TERM=xterm # Nécessaire pour la gestion tput des sorties log
0 */3 * * * /path/to/script/g1-stats.sh web >> /var/log/g1-stats.log 2>&1
```

View File

@ -128,15 +128,6 @@ anniversary() {
jq "$jqNewUD" <<<$jsonData
}
today() {
todayDate=$(date +'%d-%m-%y')
jq '.[] | select(.date=="'$todayDate'")' <<<$jsonData
}
update() {
curl -s https://g1-stats.axiom-team.fr/data/daily.json > $jsonFile && echo "Data have been updated" || echo "Error: Can't update data"
}
print() {
jq . <<<"$jsonData"
}

View File

@ -30,7 +30,6 @@ if $debug; then
echo # To clean next progress view
else
TXBLOCKS=$(curl -s ${DUNITER}/blockchain/with/tx | jq '.result.blocks[]')
# TXBLOCKS=$(cat $GPATH/tx.json | jq '.result.blocks[]')
echo "TXBLOCKS OK"
membresPubkeys=$(curl -s ${DUNITER}/wot/members | jq -r '.results[].pubkey')
tput cuu1;tput el;

View File

@ -54,7 +54,7 @@ web() {
sed -i "s/_pourcentSimpleWallet/$pourcentSimpleWallet/g" $indexhtml
sed -i "s/_nonConsumedUDT/$nonConsumedUDT/g" $indexhtml
sed -i "s/_monetaryMass/$monetaryMass/g" $indexhtml
# sed -i "s/_sleepyG1/$sleepyG1/g" $indexhtml
sed -i "s/_sleepyG1/$sleepyG1/g" $indexhtml
[[ -z $(grep '"display:none;" class="previous"' $indexhtml) ]] && sed -i "s/_datePrevious/$datePrevious/g" $indexhtml && setPrevious="Oui"
[[ -z $(grep '"display:none;" class="next"' $indexhtml) ]] && sed -i "s/_dateNext/$dateNext/g" $indexhtml && setNext="Oui"
@ -132,21 +132,3 @@ Analyse
---
$sleepyG1% des Ḡ1 n'ont jamais été utilisés."
}
rmOldCache() {
keepCache=20
listCache=$(ls -l $GPATH/db/bk-* | awk '{ print $9 }')
listID=$(echo "$listCache" | awk -F '-' '{ print $NF }')
nbrID=$(echo "$listID" | wc -l)
nbrToSup=$((nbrID-$keepCache))
if [[ $nbrToSup -ge 0 ]]; then
cacheIDToSup=$(echo "$listID" | head -n$nbrToSup)
for i in $cacheIDToSup; do
rm $GPATH/db/bk-daily.json-$i
rm $GPATH/cache/bk-walletsUp-$i
done
fi
}

View File

@ -13,8 +13,8 @@ scanTxWallets() {
local nbrMembersYesterday=$(cat "$startFile" | sed -e '1,/---/d' | sed -e '1,/---/d' | sed '/---/Q' | grep . | cut -d '|' -f 1)
local blockDateLast=$(cat "$startFile" | sed -e '1,/---/d' | sed -e '1,/---/d' | sed '/---/Q' | grep . | cut -d '|' -f 2)
local nbrDays=$(cat "$startFile" | sed -e '1,/---/d' | sed -e '1,/---/d' | sed '/---/Q' | grep . | cut -d '|' -f 3)
#! ($debug) &&
[[ $lastBloc -le $startBloc || $startIter -ge ${#TXBLOCKS[@]} ]] && echo "$lastBloc -le $startBloc || $startIter -ge ${#TXBLOCKS[@]}" && return
#! ($debug) &&
[[ $lastBloc -le $startBloc || $startIter -ge ${#TXBLOCKS[@]} ]] && return
rm $startFile
else
local startIter=0
@ -24,7 +24,6 @@ scanTxWallets() {
fi
incExec=1
for ((i=$startIter; i<${#TXBLOCKS[@]}; i++)); do
local nbrIteration=$i
local startExec=$(($(date +%s%N)/1000000))
local bloc=${TXBLOCKS[$i]}
[[ -z $bloc ]] && break
@ -32,11 +31,6 @@ scanTxWallets() {
# Récupération du bloc courant
local blocFull=$(curl -s ${DUNITER}/blockchain/block/$bloc)
while [[ $(jq -r '.ucode' <<<"$blocFull") == 1006 ]]; do
[[ $isWeb != "web" ]] && echo -e "i: $i\n$blocFull"
sleep 2
blocFull=$(curl -s ${DUNITER}/blockchain/block/$bloc)
done
until blocBrut=$(jq -r '.' <<<"$blocFull" 2>/dev/null); do
[[ $isWeb != "web" ]] && echo -e "i: $i\n$blocFull"
sleep 2
@ -44,10 +38,6 @@ scanTxWallets() {
done
[[ -z "$blocBrut" ]] && continue
echo "$blocFull" > debugTmp.txt
echo "-----------------------------------" >> debugTmp.txt
echo "$blocBrut" >> debugTmp.txt
# Récupération de la date du block
local blockDate=$(jq '.medianTime' <<<"$blocBrut")
#kopa echo "$blocBrut"
@ -151,23 +141,6 @@ scanTxWallets() {
nbrMembersToday=$(($nbrMembersTotalToday-$nbrMembersYesterday))
jsonify
# Mise en cache périodique
## On supprime les doublons et les lignes vides
wallets=$(echo -e "$wallets" | sort -u | awk 'NF')
# if ((i % 50 == 0)); then #kopaa
echo -e "$bloc\n$wallets\n---\n$walletsAuj\n---\n$nbrMembersYesterday|$blockDateLast|$nbrDays" > $GPATH/cache/bk-walletsUp-$nbrIteration
cp $GPATH/db/daily.json $GPATH/db/bk-daily.json-$nbrIteration
## Retire la dernière virgule et ajoute le crochet de fin de JSON
sed -i '$ s/,//g' $GPATH/db/bk-daily.json-$nbrIteration
echo "]" >> $GPATH/db/bk-daily.json-$nbrIteration
## On supprime le vieux cache
rmOldCache
# fi
}
if [[ -n $blockDateLast && $blockDateLast != $blockDate ]]; then

View File

@ -1,23 +0,0 @@
#!/bin/bash
# Récupération du chemin absolut du répertoir du script actuel
GPATH="$( cd "$(dirname "$0")" ; pwd -P )/.."
[[ ! -f $GPATH/.env ]] && cp $GPATH/.env.example $GPATH/.env
source $GPATH/.env
log="/var/log/geoloc-members.log"
echo "### $(date +'%d-%m-%y - %H:%M') ###" >> $log
result=$($JAKLIS geolocProfiles)
finalResult=$(echo "$result" | jq .)
RESULT=$?
if [ $RESULT -eq 0 ]; then
echo "$finalResult" > $WEBPATH/data/geoloc-members.json
echo "OK" >> $log
else
echo "Failed" >> $log
fi
echo "---" >> $log

View File

@ -1,66 +0,0 @@
#!/bin/bash
# Récupération du chemin absolut du répertoir du script actuel
GPATH="$( cd "$(dirname "$0")" ; pwd -P )/.."
[[ ! -f $GPATH/.env ]] && cp $GPATH/.env.example $GPATH/.env
source $GPATH/.env
node=$(cut -d '/' -f3 <<<"$DUNITER")
#Check if Jaklis is installed
[[ -z $JAKLIS ]] && JAKLIS=$(which silkaj)
[[ -z $JAKLIS ]] && echo "Erreur: Vous devez installer Jaklis." && exit 1
work() {
for i in $wallets; do
exec() {
jsonResult=$($JAKLIS idBalance -p $i 2>/dev/null)
}
exec
while [[ $? == 1 ]]; do echo "Erreur $k: $i"; ((k++)); exec; done
unset k
balance=$(echo "$jsonResult" | jq -r '.balance')
[[ $balance == "null" ]] && balance="0"
username=$(echo "$jsonResult" | jq -r '.idty.username')
[[ $username == "null" ]] && username=""
formatedBalance=$(printf "%-10s | %-45s | %-1s" $balance $i $username)
if [[ $1 == "members" ]]; then
htmlBloc="$htmlBloc"$'\n'"<tr><td>$balance</td><td>$i</td><td><b>$username</b></td></tr>"
unset username
else
htmlBloc="$htmlBloc"$'\n'"<tr><td>$balance</td><td>$i</td><td>$username</td></tr>"
fi
unset balance
echo "$formatedBalance" | tee -a /tmp/balance-g1.txt
totalBalance="$totalBalance"$'\n'"$formatedBalance"
echo "$jsonResult" >> /home/poka/debugJsonForbes.log
# For tests only
# [[ $i == "13fn6X3XWVgshHTgS8beZMo9XiyScx6MB6yPsBB5ZBia" ]] && break
# [[ $i == "12JDJibbgZPRfD6Hoecg8rQRvCR5VYrMnqzfhQYmAr3k" ]] && break
done
}
wallets=$(cat $WEBPATH/data/wallets-g1-membres.txt 2>/dev/null)
[[ -z $wallets ]] && wallets=$(curl -s https://g1-stats.axiom-team.fr/data/wallets-g1-membres.txt)
work members && unset wallets
wallets=$(cat $WEBPATH/data/wallets-g1-simple.txt 2>/dev/null)
[[ -z $wallets ]] && wallets=$(curl -s https://g1-stats.axiom-team.fr/data/wallets-g1-simple.txt)
work && unset wallets
totalBalance=$(sort -nr <<<$totalBalance)
[[ ! -d $GPATH/db ]] && mkdir $GPATH/db
grep . <<<"$totalBalance" > $GPATH/db/wallets_balance.txt && rm /tmp/balance-g1.txt
# Construct HTML
cp $GPATH/tpl/css/wallets_balance.css $WEBPATH/css/
cp $GPATH/tpl/js/wallets_balance.js $WEBPATH/js/
cp $GPATH/tpl/wallets_balance.html $WEBPATH/data/wallets_balance.html
sort -Vr <<<"$htmlBloc" > /tmp/solde_g1_html.txt
printf '%s\n' '/_LINE/r /tmp/solde_g1_html.txt' 1 '/_LINE/d' w | ed $WEBPATH/data/wallets_balance.html > /dev/null
sed -i "0,/_DATE/s//$(date '+%d-%m-%Y')/" $WEBPATH/data/wallets_balance.html
rm /tmp/solde_g1_html.txt

View File

@ -1,12 +1,70 @@
#!/bin/bash
# Récupération du chemin absolut du répertoir du script actuel
# Récupération du chemin absolu du répertoire du script actuel
GPATH="$( cd "$(dirname "$0")" ; pwd -P )/.."
[[ ! -f $GPATH/.env ]] && cp $GPATH/.env.example $GPATH/.env
source $GPATH/.env
node=$(cut -d '/' -f3 <<<"$DUNITER")
$JAKLIS listWallets > $WEBPATH/data/forbes.json
#Check if ed is installed
which ed || { echo "$0: Error: please install ed" >&2 ; exit 1 ; }
date=$(date -d '+1 minute' +"%d/%m/%Y à %H:%M")
#Check if Jaklis or silkaj is installed
if [[ "$JAKLIS" ]] ; then
exec() {
jsonResult=$($JAKLIS idBalance -p $i) || return $?
balance=$(echo "$jsonResult" | jq -r '.balance')
username=$(echo "$jsonResult" | jq -r '.username')
}
elif which silkaj ; then
exec() {
balance=$(silkaj -p "$node" balance "$i") || return $?
balance=$(sed -n 's,.* \([\.0-9]\+\) Ğ1.*,\1,p' <<<$balance)
username=$(silkaj -p "$node" id "$i") || return $?
username=$(sed -n 's,.*: \(.*\)$,\1,p' <<<$username)
}
else
echo "$0: Error: you should use Jaklis or install silkaj." >&2
exit 1
fi
sed -i "/<div id=\"dataDate\">/!b;n;cCes données ont été actualisées le $date" $WEBPATH/data/search.html
work() {
for i in $wallets; do
((j++))
# For tests only
#(( j > 42 )) && break
unset k
while ! exec ; do echo "Erreur $?: retry=$((k)) wallet=$i"; ((k++ > 9999)) && break ; sleep $((RANDOM%8)) ; done
formatedBalance=$(printf "%-10s | %-45s | %-1s" $balance $i $username)
[[ $1 == "members" ]] && username="<b>$username</b>"
htmlBloc="$htmlBloc<td>$balance</td><td><a id=\"k$i\" href=\"payto://g1/$i\">$i</a></td><td><b>$username</b></td>"$'\n'
echo "$formatedBalance" | tee -a /tmp/balance-g1.txt | sed "s,^,$j | ,"
totalBalance="$totalBalance$formatedBalance"$'\n'
done
}
wallets=$(cat $WEBPATH/data/wallets-g1-membres.txt 2>/dev/null)
[[ -z $wallets ]] && wallets=$(curl -s https://g1-stats.axiom-team.fr/data/wallets-g1-membres.txt)
work members && unset wallets
wallets=$(cat $WEBPATH/data/wallets-g1-simple.txt 2>/dev/null)
[[ -z $wallets ]] && wallets=$(curl -s https://g1-stats.axiom-team.fr/data/wallets-g1-simple.txt)
work && unset wallets
totalBalance=$(sort -nr <<<$totalBalance)
[[ ! -d $GPATH/db ]] && mkdir $GPATH/db
grep . <<<"$totalBalance" > $GPATH/db/wallets_balance.txt && rm /tmp/balance-g1.txt
# Construct HTML
cp $GPATH/tpl/css/wallets_balance.css $WEBPATH/css/
cp $GPATH/tpl/js/wallets_balance.js $WEBPATH/js/
cp $GPATH/tpl/wallets_balance.html $WEBPATH/data/wallets_balance.html
sort -Vr <<<"$htmlBloc" | awk '{ print "<tr id=\"p"NR"\"><td>"NR"</td>"$0"</tr>" ; }' > /tmp/solde_g1_html.txt
printf '%s\n' '/_LINE/r /tmp/solde_g1_html.txt' 1 '/_LINE/d' w | ed $WEBPATH/data/wallets_balance.html > /dev/null
sed -i "0,/_DATE/s//$(date '+%d-%m-%Y')/" $WEBPATH/data/wallets_balance.html
rm /tmp/solde_g1_html.txt

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,43 +1,8 @@
body {
background-color: #c4a787 !important;
margin-top: 10px !important;
margin-left: 20px !important;
margin-right: 20px !important;
font-family: "Gill Sans", sans-serif !important;
}
.bootstrap-table .fixed-table-toolbar .bs-bars, .bootstrap-table .fixed-table-toolbar .columns, .bootstrap-table .fixed-table-toolbar .search {
float: inherit !important;
text-align: center;
display:flex;
justify-content:center;
}
.form-control {
height: calc(1.5em + .75rem + 20px) !important;
width: 500px !important;
}
.bootstrap-table .fixed-table-container .fixed-table-body {
height: inherit !important;
}
.bootstrap-table .fixed-table-container {
background-color: #DFCFBE;
border-collapse: collapse !important; /* Collapse borders */
border: 1px solid #ddd !important; /* Add a grey border */
font-size: 16px !important; /* Increase font-size */
}
.bootstrap-table .fixed-table-container th {
background-color: #B69776;
}
#dataDate {
position: absolute;
left: 50%;
transform: translate(-50%, -50%);;
bottom: 0;
background-color: #c4a787;
margin-top: 10px;
margin-left: 20px;
font-family: "Gill Sans", sans-serif;
}
.date {
@ -82,7 +47,6 @@ body {
/* Add a grey background color to the table header and on hover */
background-color: #B69776;
cursor: pointer;
position: sticky;
top: 0px;
}

View File

@ -13,45 +13,47 @@
<div class="header">
<center><h1>Ḡ1 Stats</h1>
| <a href="/data/daily.json">Voir le JSON g1stats</a>
| <a href="/data/search.html">Recherche</a>
| <a href="/data/daily.json">Voir le fichier JSON</a>
| <a href="/data/wallets-g1.txt">Liste de tous les wallets</a>
| <a href="/data/wallets-g1-membres.txt">Liste des wallets membres</a>
| <a href="/data/wallets-g1-simple.txt">Liste des simples portefeuilles</a>
| <a href="/data/geoloc-members.json">Voir le JSON profiles membres</a> |
| <a href="/data/wallets_balance.html">Classement FORBES</a> |
</center>
</div>
<div id="mainbloc">
<pre>
Date: <b>_day - _heure</b>
Noeud scanné: <b>https://g1v1.p2p.legal</b>
Date: <b>_day - _heure</b>
Noeud scanné: <b>https://duniter-g1.p2p.legal</b>
---
Nombre total de portefeuille: <b>_nbrTotalWallets</b>
Nombre total de wallet: <b>_nbrTotalWallets</b>
Nombre de membres: <b>_nbrMembers</b> (_pourcentMbrs%)
Nombre de simple portefeuille: <b>_nbrSimpleWallets</b> (_pourcentWallets%)
Nombre de simple portefeuille: <b>_nbrSimpleWallets</b> (_pourcentWallets%)
---
Reçus simples portefeuille: <b>_sumRW Ḡ1</b>
Envoyé simples portefeuille: <b>_sumSW Ḡ1</b>
Soldes simples portefeuille: <b>_soldeW Ḡ1</b> (_pourcentSimpleWallet% de la masse monétaire totale)
Envoyé simples portefeuille: <b>_sumSW Ḡ1</b>
Soldes simples portefeuille: <b>_soldeW Ḡ1</b> (_pourcentSimpleWallet% de la masse monétaire totale)
---
Reçus membres: <b>_sumRM Ḡ1</b> (sans les DU)
Envoyé membres: <b>_sumSM Ḡ1</b>
Soldes membres: <b>_soldeM Ḡ1</b> (sans les DU)
---
Masse monétaire: <b>_monetaryMass Ḡ1</b>
Masse monétaire: <b>_monetaryMass Ḡ1</b>
---
<h3>Analyse rapide</h3>
<b>_sleepyG1%</b> des Ḡ1 n'ont jamais été utilisés.
</pre>
</div>
<div id="charts">
<center><h2 id="titleRW">Ḡ1 reçus sur les portefeuilles</h2></center>
<center><h2 id="titleRW">Ḡ1 reçus sur les wallets</h2></center>
<canvas id="chartRW" width="1600" height="500"></canvas>
</div>
</center>
<div id="charts">
<center><h2 id="titleNBRW">Nombre de portefeuilles</h2></center>
<center><h2 id="titleNBRW">Nombre de wallets</h2></center>
<canvas id="chartNBRW" width="1600" height="500"></canvas>
</div>
</center>

View File

@ -23,25 +23,8 @@ var jsonfileRW = $.getJSON( "../data/cum-daily.json", function(data) {
type: 'line',
data: {
labels: date,
datasets: [
{
label: 'Portefeuilles membres',
data: rmembers,
backgroundColor: 'rgba(0, 178, 0, 0.3)',
pointBorderWidth: 1,
pointHoverRadius: 6,
pointHoverBackgroundColor: "beige",
pointHoverBorderColor: "brown",
pointHoverBorderWidth: 2,
pointRadius: 1,
pointHitRadius: 4
},
{
label: 'Simples portefeuilles',
datasets: [{
label: 'Ḡ1 reçus sur les simples portefeuilles',
data: rwallets,
backgroundColor: 'rgba(0, 119, 204, 0.3)',
pointBorderWidth: 1,
@ -51,31 +34,22 @@ var jsonfileRW = $.getJSON( "../data/cum-daily.json", function(data) {
pointHoverBorderWidth: 2,
pointRadius: 1,
pointHitRadius: 4
},
]
}, {
label: 'Ḡ1 reçus sur les portefeuilles membres',
data: rmembers,
backgroundColor: 'rgba(0, 178, 0, 0.3)',
pointBorderWidth: 1,
pointHoverRadius: 6,
pointHoverBackgroundColor: "beige",
pointHoverBorderColor: "brown",
pointHoverBorderWidth: 2,
pointRadius: 1,
pointHitRadius: 4
}]
},
options: {
maintainAspectRatio: false,
responsive: true,
scales: {
xAxes: [{
stacked: true
}],
yAxes: [
{
id: 'y-axis',
stacked: true
}
]
}
responsive: true
}
};
var myChartRW = new Chart(ctx, config);
@ -87,11 +61,10 @@ scales: {
type: 'line',
data: {
labels: date,
datasets: [
{
label: 'Portefeuilles membres',
data: nbrmembers,
backgroundColor: 'rgba(0, 178, 0, 0.3)',
datasets: [{
label: 'Nombre de simple portefeuilles',
data: nbrwallets,
backgroundColor: 'rgba(0, 119, 204, 0.3)',
pointBorderWidth: 1,
pointHoverRadius: 6,
pointHoverBackgroundColor: "beige",
@ -99,12 +72,10 @@ scales: {
pointHoverBorderWidth: 2,
pointRadius: 1,
pointHitRadius: 4
},
{
label: 'Simples portefeuilles',
data: nbrwallets,
backgroundColor: 'rgba(0, 119, 204, 0.3)',
}, {
label: 'Nombre de portefeuilles membres',
data: nbrmembers,
backgroundColor: 'rgba(0, 178, 0, 0.3)',
pointBorderWidth: 1,
pointHoverRadius: 6,
pointHoverBackgroundColor: "beige",
@ -116,21 +87,7 @@ scales: {
},
options: {
maintainAspectRatio: true,
responsive: true,
scales: {
xAxes: [{
stacked: true
}],
yAxes: [
{
id: 'y-axis',
stacked: true
}
]
}
responsive: true
}
};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,39 +0,0 @@
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="../css/wallets_balance.css">
<link rel="stylesheet" href="../css/src/bootstrap.min.css">
<link rel="stylesheet" href="../css/src/bootstrap-table.min.css">
<script src="../js/src/jquery.min.js"></script>
<script src="../js/src/popper.min.js"></script>
<script src="../js/src/bootstrap.min.js"></script>
<script src="../js/src/bootstrap-table.min.js"></script>
<script src="../js/src/bootstrap-table-fr-FR.min.js"></script>
</head>
<body>
<table id="walletsTable" data-toggle="table" data-locale="fr-FR" data-pagination="true" data-page-size='10' data-page-list="[10, 25, 50, 100, 500, all]" data-search="true" data-url="forbes.json">
<thead>
<tr>
<th data-sortable="true" data-field="pubkey">Clé publique</th>
<th data-sortable="true" data-field="id.username">Pseudo</th>
<th data-sortable="true" data-field="id.isMember">Membre</th>
<th data-sortable="true" data-field="balance">Solde (Ğ1)</th>
</tr>
</thead>
</table>
<br><br>
<center>
<div id="dataDate">
Ces données ont été actualisées le 18/10/2021 à 06:16
</div>
</center>
</body>
</html>

View File

@ -10,7 +10,7 @@
<input type="checkbox" id="splw" value="splw" checked><label for="splw">Afficher les simples portefeuilles</label>
<table id="soldes">
<tr><th>Solde (Ḡ1)</th><th>Clé publique</th><th>Identifiant utilisateur</th></tr>
<tr><th>Position</th><th>Solde (Ḡ1)</th><th>Clé publique</th><th>Identifiant utilisateur</th></tr>
_LINE
</table>