gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libeufin] branch master updated: /monitor testing: script to populate t


From: gnunet
Subject: [libeufin] branch master updated: /monitor testing: script to populate the database.
Date: Wed, 22 Nov 2023 15:51:49 +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 1ced32c4 /monitor testing: script to populate the database.
1ced32c4 is described below

commit 1ced32c441385a44aed7237a01c1953cdd6ee6a4
Author: MS <ms@taler.net>
AuthorDate: Wed Nov 22 15:50:48 2023 +0100

    /monitor testing: script to populate the database.
---
 contrib/populate-stats.sh | 62 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)

diff --git a/contrib/populate-stats.sh b/contrib/populate-stats.sh
new file mode 100755
index 00000000..f93c5474
--- /dev/null
+++ b/contrib/populate-stats.sh
@@ -0,0 +1,62 @@
+#!/bin/bash
+
+# This script populates the stats table, to test the /monitor API.
+
+usage() {
+  echo "Usage: ./populate-stats.sh CONFIG_FILE"
+  echo
+  echo "Populates the stats table with random data"
+}
+
+# Detecting the help case.
+if test "$1" = "--help" -o "$1" = "-h" -o -z ${1:-};
+  then usage
+  exit
+fi
+set -eu
+
+DB_NAME=$(taler-config -c $1 -s libeufin-bankdb-postgres -o config)
+echo Running on the database: $DB_NAME
+
+# random number in range $1-$2
+rnd () {
+  shuf -i $1-$2 -n1
+}
+
+# $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'
+        ,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
+done

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]