forked from axiom-team/g1-stats
Add jo to install for explorer usage; reduce roundit in one line in cumulate.jq; Add several functions in explorer
This commit is contained in:
parent
e7686377d2
commit
e04767d59d
|
@ -5,3 +5,4 @@ cache
|
|||
debug.log
|
||||
bk-debug.log
|
||||
bk
|
||||
.gitPushToMaster.sh
|
||||
|
|
45
explorer.sh
45
explorer.sh
|
@ -4,11 +4,22 @@
|
|||
GPATH="$( cd "$(dirname "$0")" ; pwd -P )"
|
||||
source $GPATH/.env
|
||||
|
||||
# Parse options
|
||||
for i in $@; do
|
||||
case "$i" in
|
||||
-c|--cumulate) echo "On cumule !";;
|
||||
-h|--help) echo "Demande d'aide";;
|
||||
*) isOptions+="$i|";;
|
||||
esac
|
||||
done
|
||||
|
||||
jsonFile="$GPATH/db/daily.json"
|
||||
cmd=$1
|
||||
dateRange=$2
|
||||
[[ -z $dateRange ]] && dateRange=$(jq -r '.[].date' $jsonFile | tail -n1)
|
||||
[[ ! $(grep $dateRange $jsonFile) ]] && echo "La date $dateRange n'existe pas en cache G1Stats" && exit 1
|
||||
cmd=$(cut -d'|' -f1 <<<"$isOptions")
|
||||
dateRange=$(cut -d'|' -f2 <<<"$isOptions")
|
||||
args="$(cut -d'|' -f2- <<<"$isOptions" | sed 's/.$//' | tr '|' ' ')"
|
||||
|
||||
[[ -z "$dateRange" ]] && dateRange=$(jq -r '.[].date' $jsonFile | tail -n1)
|
||||
[[ ! $(grep "$dateRange" $jsonFile) && $cmd != "select" ]] && echo "La date $dateRange n'existe pas en cache G1Stats" && exit 1
|
||||
|
||||
cumulate() {
|
||||
jsonCum="$(jq -f $GPATH/lib/cumulate.jq $jsonFile)"
|
||||
|
@ -24,6 +35,28 @@ mass() {
|
|||
jq '.[] | .UD*.nbrMembers' <<<"$jsonDated" | awk '{ SUM += $1} END { printf "%.2f", SUM }'; echo
|
||||
}
|
||||
|
||||
[[ -z $cmd ]] && cmd=cumulate
|
||||
solde() {
|
||||
cumDay=$(day)
|
||||
soldeWallets=$(jq '(.rWallets-.sWallets)*100.0+ 0.5|floor/100.0' <<<$cumDay)
|
||||
soldeMembers=$(jq '(.rMembers-.sMembers)*100.0+ 0.5|floor/100.0' <<<$cumDay)
|
||||
jo -p date=$dateRange soldeWallets=$soldeWallets soldeMembers=$soldeMembers | jq .
|
||||
}
|
||||
|
||||
total() {
|
||||
cumDay=$(day)
|
||||
totalReceived=$(jq '(.rWallets+.rMembers)*100.0+ 0.5|floor/100.0' <<<$cumDay)
|
||||
totalSent=$(jq '(.sWallets+.sMembers)*100.0+ 0.5|floor/100.0' <<<$cumDay)
|
||||
jo -p date=$dateRange totalReceived=$totalReceived totalSent=$totalSent | jq .
|
||||
}
|
||||
|
||||
selectFunc() {
|
||||
jq '.[] | select('"$args"')' $jsonFile
|
||||
}
|
||||
|
||||
|
||||
case $cmd in
|
||||
select) selectFunc;;
|
||||
'') cumulate;;
|
||||
*) $cmd;;
|
||||
esac
|
||||
|
||||
$cmd
|
||||
|
|
|
@ -21,7 +21,7 @@ startTime=$(date +'%H:%M')
|
|||
day=$(date +'%y-%m-%d')
|
||||
dayP=$(date +'%d-%m-%y')
|
||||
echo -e "\n############# $day à $startTime #############\n"
|
||||
[[ -z $(which jq) || -z $(which bc) || -z $(which curl) ]] && sudo apt update && sudo apt install jq bc curl
|
||||
[[ -z $(which jq) || -z $(which jo) || -z $(which bc) || -z $(which curl) ]] && sudo apt update && sudo apt install jq jo bc curl
|
||||
echo "Initialisation ..."
|
||||
if $debug; then
|
||||
TXBLOCKS=$(cat $GPATH/db/debug/txblocs)
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
def round: . + 0.5 | floor;
|
||||
def roundit: .*100.0|round/100.0;
|
||||
def roundit: (.*100.0)+ 0.5|floor/100.0;
|
||||
[foreach .[] as $row (null;
|
||||
.nbrMembers += $row.nbrMembers |
|
||||
.nbrWallets += $row.nbrWallets |
|
||||
|
|
Loading…
Reference in New Issue