gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated (f6c766f6 -> f6a678ba)


From: gnunet
Subject: [libeufin] branch master updated (f6c766f6 -> f6a678ba)
Date: Fri, 19 Jan 2024 17:51:18 +0100

This is an automated email from the git hooks/post-receive script.

antoine pushed a change to branch master
in repository libeufin.

    from f6c766f6 Remove development features from libeufin-nexus and hide 
options that will be removed in the next version
     new 56dbde40 Restore the ebics-fetch import function in libeufin-nexus, as 
we use it to configure regional currencies, but keep it hidden.
     new f6a678ba Make timezone explicit in stats logic

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../main/kotlin/tech/libeufin/bank/db/Database.kt  |  2 +-
 bank/src/test/kotlin/StatsTest.kt                  |  4 ++--
 database-versioning/libeufin-bank-procedures.sql   | 14 +++++++++----
 .../main/kotlin/tech/libeufin/nexus/EbicsFetch.kt  | 23 +++++++++++-----------
 4 files changed, 25 insertions(+), 18 deletions(-)

diff --git a/bank/src/main/kotlin/tech/libeufin/bank/db/Database.kt 
b/bank/src/main/kotlin/tech/libeufin/bank/db/Database.kt
index 6f692fd0..27cbfc2f 100644
--- a/bank/src/main/kotlin/tech/libeufin/bank/db/Database.kt
+++ b/bank/src/main/kotlin/tech/libeufin/bank/db/Database.kt
@@ -111,7 +111,7 @@ class Database(dbConfig: String, internal val bankCurrency: 
String, internal val
                 ,taler_out_count
                 ,(taler_out_volume).val as taler_out_volume_val
                 ,(taler_out_volume).frac as taler_out_volume_frac
-            FROM stats_get_frame(now()::timestamp, ?::stat_timeframe_enum, ?)
+            FROM stats_get_frame(NULL, ?::stat_timeframe_enum, ?)
         """)
         stmt.setString(1, params.timeframe.name)
         if (params.which != null) {
diff --git a/bank/src/test/kotlin/StatsTest.kt 
b/bank/src/test/kotlin/StatsTest.kt
index da239674..7ec5c7d0 100644
--- a/bank/src/test/kotlin/StatsTest.kt
+++ b/bank/src/test/kotlin/StatsTest.kt
@@ -160,8 +160,8 @@ class StatsTest {
                         frac = it.getInt("taler_out_volume_frac"),
                         currency = "KUDOS"
                     )
-                    assertEquals(count, talerOutCount)
-                    assertEquals(amount, talerOutVolume)
+                    assertEquals(count, talerOutCount, "taler count")
+                    assertEquals(amount, talerOutVolume, "taler volume")
                 }!!
             }
 
diff --git a/database-versioning/libeufin-bank-procedures.sql 
b/database-versioning/libeufin-bank-procedures.sql
index 99b0bee3..89243c2c 100644
--- a/database-versioning/libeufin-bank-procedures.sql
+++ b/database-versioning/libeufin-bank-procedures.sql
@@ -226,7 +226,7 @@ INSERT
 SELECT (amount).val, (amount).frac, bank_account_id
 INTO local_amount.val, local_amount.frac, local_bank_account_id
 FROM bank_account_transactions WHERE bank_transaction_id=in_debit_row_id;
-CALL stats_register_payment('taler_out', now()::TIMESTAMP, local_amount, null);
+CALL stats_register_payment('taler_out', NULL, local_amount, null);
 -- notify new transaction
 PERFORM pg_notify('outgoing_tx', in_debtor_account_id || ' ' || 
in_creditor_account_id || ' ' || in_debit_row_id || ' ' || in_credit_row_id);
 END $$;
@@ -255,7 +255,7 @@ INSERT
 SELECT (amount).val, (amount).frac, bank_account_id
 INTO local_amount.val, local_amount.frac, local_bank_account_id
 FROM bank_account_transactions WHERE bank_transaction_id=in_tx_row_id;
-CALL stats_register_payment('taler_in', now()::TIMESTAMP, local_amount, null);
+CALL stats_register_payment('taler_in', NULL, local_amount, null);
 -- notify new transaction
 PERFORM pg_notify('incoming_tx', local_bank_account_id || ' ' || in_tx_row_id);
 END $$;
@@ -1034,7 +1034,7 @@ END IF;
 CALL register_incoming(in_reserve_pub, tx_row_id);
 
 -- update stats
-CALL stats_register_payment('cashin', now()::TIMESTAMP, converted_amount, 
in_amount);
+CALL stats_register_payment('cashin', NULL, converted_amount, in_amount);
 
 END $$;
 COMMENT ON FUNCTION cashin IS 'Perform a cashin operation';
@@ -1142,7 +1142,7 @@ INSERT INTO cashout_operations (
 ) RETURNING cashout_id INTO out_cashout_id;
 
 -- update stats
-CALL stats_register_payment('cashout', now()::TIMESTAMP, in_amount_debit, 
in_amount_credit);
+CALL stats_register_payment('cashout', NULL, in_amount_debit, 
in_amount_credit);
 END $$;
 
 CREATE FUNCTION tan_challenge_create (
@@ -1321,6 +1321,9 @@ LANGUAGE plpgsql AS $$
 DECLARE
   local_start_time TIMESTAMP;
 BEGIN
+  IF now IS NULL THEN
+    now = timezone('utc', now())::TIMESTAMP;
+  END IF;
   local_start_time = CASE 
     WHEN which IS NULL          THEN date_trunc(in_timeframe::text, now)
     WHEN in_timeframe = 'hour'  THEN date_trunc('day'  , now) + 
make_interval(hours  => which)
@@ -1378,6 +1381,9 @@ DECLARE
   frame stat_timeframe_enum;
   query TEXT;
 BEGIN
+  IF now IS NULL THEN
+    now = timezone('utc', now())::TIMESTAMP;
+  END IF;
   IF fiat_amount IS NULL THEN
     query = format('INSERT INTO bank_stats AS s '
       '(timeframe, start_time, %1$I_count, %1$I_volume) '
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/EbicsFetch.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/EbicsFetch.kt
index cfebfb1e..1b180f07 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/EbicsFetch.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/EbicsFetch.kt
@@ -66,10 +66,6 @@ data class FetchContext(
      * EBICS version.  For the HAC message type, version gets switched to 
EBICS 2.
      */
     var ebicsVersion: EbicsVersion,
-    /**
-     * Logs to STDERR the init phase of an EBICS download request.
-     */
-    val ebicsExtraLog: Boolean,
     /**
      * Start date of the returned documents.  Only
      * used in --transient mode.
@@ -110,8 +106,7 @@ private suspend inline fun downloadHelper(
             ebics2Req.orderParams
         )
     }
-    if (ctx.ebicsExtraLog)
-        logger.debug(initXml)
+    logger.trace(initXml)
     try {
         return doEbicsDownload(
             ctx.httpClient,
@@ -373,7 +368,7 @@ private fun ingestDocument(
                     content.unzipForEach { fileName, xmlContent ->
                         if (!fileName.contains("camt.054", ignoreCase = true))
                             throw Exception("Asked for notification but did 
NOT get a camt.054")
-                        logger.trace("parse $fileName")
+                        logger.debug("parse $fileName")
                         parseTxNotif(xmlContent, currency, incomingPayments, 
outgoingPayments)
                     }
                 } catch (e: IOException) {
@@ -500,8 +495,8 @@ class EbicsFetch: CliktCommand("Fetches bank records.  
Defaults to camt.054 noti
                 " latest document is always until the current time."
     )
 
-    private val ebicsExtraLog by option(
-        help = "Logs to STDERR the init phase of an EBICS download request",
+    private val import by option(
+        help = "Read one ISO20022 document from STDIN and imports its content 
into the database",
         hidden = true
     ).flag(default = false)
 
@@ -524,6 +519,13 @@ class EbicsFetch: CliktCommand("Fetches bank records.  
Defaults to camt.054 noti
         if (onlyLogs) whichDoc = SupportedDocument.PAIN_002_LOGS
 
         Database(dbCfg.dbConnStr).use { db ->
+            if (import) {
+                logger.debug("Reading from STDIN")
+                val stdin = 
generateSequence(::readLine).joinToString("\n").toByteArray()
+                ingestDocument(db, cfg.currency, stdin, whichDoc)
+                return@cliCmd
+            }
+
             val (clientKeys, bankKeys) = expectFullKeys(cfg)
             val ctx = FetchContext(
                 cfg,
@@ -531,8 +533,7 @@ class EbicsFetch: CliktCommand("Fetches bank records.  
Defaults to camt.054 noti
                 clientKeys,
                 bankKeys,
                 whichDoc,
-                EbicsVersion.three,
-                ebicsExtraLog
+                EbicsVersion.three
             )
             if (transient) {
                 logger.info("Transient mode: fetching once and returning.")

-- 
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]