[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] branch master updated: populating stats
From: |
gnunet |
Subject: |
[libeufin] branch master updated: populating stats |
Date: |
Mon, 27 Nov 2023 14:07:00 +0100 |
This is an automated email from the git hooks/post-receive script.
ms pushed a commit to branch master
in repository libeufin.
The following commit(s) were added to refs/heads/master by this push:
new 74675660 populating stats
74675660 is described below
commit 746756605b41d22e49454e95b38338b6fdb07059
Author: MS <ms@taler.net>
AuthorDate: Mon Nov 27 14:06:10 2023 +0100
populating stats
---
contrib/populate-stats.sh | 83 ++++++++++++++++++++++++++---------------------
1 file changed, 46 insertions(+), 37 deletions(-)
diff --git a/contrib/populate-stats.sh b/contrib/populate-stats.sh
index 63a31d3f..319ffd9c 100755
--- a/contrib/populate-stats.sh
+++ b/contrib/populate-stats.sh
@@ -3,9 +3,13 @@
# This script populates the stats table, to test the /monitor API.
usage() {
- echo "Usage: ./populate-stats.sh CONFIG_FILE"
+ echo "Usage: ./populate-stats.sh CONFIG_FILE [--one]"
echo
echo "Populates the stats table with random data"
+ echo
+ echo Parameters:
+ echo
+ echo --one instead of random amounts, it always uses 1.0
}
# Detecting the help case.
@@ -13,8 +17,13 @@ if test "$1" = "--help" -o "$1" = "-h" -o -z ${1:-};
then usage
exit
fi
-set -eu
+HAS_ONE=0
+if test "$2" = "--one";
+ then HAS_ONE=1
+fi
+
+set -eu
DB_NAME=$(taler-config -c $1 -s libeufin-bankdb-postgres -o config)
echo Running on the database: $DB_NAME
@@ -23,7 +32,36 @@ rnd () {
shuf -i $1-$2 -n1
}
-insert_stat () {
+insert_stat_one () {
+ echo "
+ SET search_path TO libeufin_bank;
+ CALL libeufin_bank.stats_register_payment (
+ 'taler_in'::text
+ ,TO_TIMESTAMP($1)::timestamp
+ ,(1, 0)::taler_amount
+ ,null
+ );
+ CALL libeufin_bank.stats_register_payment (
+ 'taler_out'::text
+ ,TO_TIMESTAMP($1)::timestamp
+ ,(1, 0)::taler_amount
+ ,null
+ );
+ CALL libeufin_bank.stats_register_payment (
+ 'cashin'::text
+ ,TO_TIMESTAMP($1)::timestamp
+ ,(1, 0)::taler_amount
+ ,(1, 0)::taler_amount
+ );
+ CALL libeufin_bank.stats_register_payment (
+ 'cashout'::text
+ ,TO_TIMESTAMP($1)::timestamp
+ ,(1, 0)::taler_amount
+ ,(1, 0)::taler_amount
+ );"
+}
+
+insert_stat_rand () {
echo "
SET search_path TO libeufin_bank;
CALL libeufin_bank.stats_register_payment (
@@ -52,41 +90,12 @@ insert_stat () {
);"
}
-# $1 == timestamp
-insert_cmd () {
- echo "
- INSERT INTO libeufin_bank.bank_stats (
- timeframe
- ,start_time
- ,taler_in_count
- ,taler_in_volume
- ,taler_out_count
- ,taler_out_volume
- ,cashin_count
- ,cashin_regional_volume
- ,cashin_fiat_volume
- ,cashout_count
- ,cashout_regional_volume
- ,cashout_fiat_volume
- ) VALUES (
- 'hour'
- ,date_trunc('hour', TO_TIMESTAMP($1))
- ,$(rnd 1 3000)
- ,($(rnd 1 1000000), $(rnd 0 99999999))
- ,$(rnd 1 3000)
- ,($(rnd 1 1000000), $(rnd 0 99999999))
- ,$(rnd 1 3000)
- ,($(rnd 1 1000000), $(rnd 0 99999999))
- ,($(rnd 1 1000000), $(rnd 0 99999999))
- ,$(rnd 1 3000)
- ,($(rnd 1 1000000), $(rnd 0 99999999))
- ,($(rnd 1 1000000), $(rnd 0 99999999))
- );"
-}
-
for n_hour_ago in `seq 1 100`; do
echo -n .
TIMESTAMP=$(date --date="${n_hour_ago} hour ago" +%s)
- # psql $DB_NAME -c "$(insert_cmd ${TIMESTAMP})" > /dev/null
- psql $DB_NAME -c "$(insert_stat ${TIMESTAMP})" > /dev/null
+ if test $HAS_ONE = 1; then
+ psql $DB_NAME -c "$(insert_stat_one ${TIMESTAMP})" > /dev/null
+ else
+ psql $DB_NAME -c "$(insert_stat_rand ${TIMESTAMP})" > /dev/null
+ fi
done
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libeufin] branch master updated: populating stats,
gnunet <=