gnunet-svn
[Top][All Lists]
Advanced

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

[taler-donau] branch master updated (60260dd -> 74f591a)


From: gnunet
Subject: [taler-donau] branch master updated (60260dd -> 74f591a)
Date: Wed, 01 May 2024 11:32:55 +0200

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

grothoff pushed a change to branch master
in repository donau.

    from 60260dd  [doc] some changes
     new 0288049  nicer SQL
     new 74f591a  bump gana

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:
 contrib/gana                                |   2 +-
 src/donaudb/pg_iterate_submitted_receipts.c | 102 +++++++---------------------
 src/include/donaudb_plugin.h                |  29 ++++----
 3 files changed, 40 insertions(+), 93 deletions(-)

diff --git a/contrib/gana b/contrib/gana
index 63ab2f3..cc2d9bd 160000
--- a/contrib/gana
+++ b/contrib/gana
@@ -1 +1 @@
-Subproject commit 63ab2f3c99c86334cc433450d7b99375ebf9d6b1
+Subproject commit cc2d9bdb3e90af5ddebf964e3da492c04a307417
diff --git a/src/donaudb/pg_iterate_submitted_receipts.c 
b/src/donaudb/pg_iterate_submitted_receipts.c
index cbcbb1e..2d187aa 100644
--- a/src/donaudb/pg_iterate_submitted_receipts.c
+++ b/src/donaudb/pg_iterate_submitted_receipts.c
@@ -27,79 +27,13 @@
 #include "donaudb_plugin.h"
 #include "donau_pq_lib.h"
 
-/**
- * Closure for #get_submitted_receipts_cb().
- */
-struct IterateSubmittedReceiptsContext
-{
-  /**
-   * Function to call per result.
-   */
-  DONAUDB_IterateSubmittedReceiptsCallback cb;
-
-  /**
-   * Closure for @e cb.
-   */
-  void *cb_cls;
-
-  /**
-   * Plugin context.
-   */
-  struct PostgresClosure *pg;
-
-};
-
-/**
- * Invoke the callback for each result.
- *
- * @param cls a `struct MissingWireContext *`
- * @param result SQL result
- * @param num_results number of rows in @a result
- */
-static void
-iterate_submitted_receipts_cb (void *cls,
-                               PGresult *result,
-                               unsigned int num_results)
-{
-  struct IterateSubmittedReceiptsContext *ctx = cls;
-  struct PostgresClosure *pg = ctx->pg;
-
-  for (unsigned int i = 0; i < num_results; i++)
-  {
-    struct TALER_Amount value;
-    enum GNUNET_GenericReturnValue iret;
-
-    struct GNUNET_PQ_ResultSpec rs[] = {
-      TALER_PQ_RESULT_SPEC_AMOUNT ("value",
-                                   &value),
-      GNUNET_PQ_result_spec_end
-    };
-
-    if (GNUNET_OK !=
-        GNUNET_PQ_extract_result (result,
-                                  rs,
-                                  i))
-    {
-      GNUNET_break (0);
-      return;
-    }
-
-    iret = ctx->cb (ctx->cb_cls,
-                    &value);
-    GNUNET_PQ_cleanup_result (rs);
-    if (GNUNET_OK != iret)
-      break;
-  }
-}
-
 
 enum GNUNET_DB_QueryStatus
 DH_PG_iterate_submitted_receipts (
   void *cls,
   const uint64_t donation_year,
   const struct DONAU_HashDonorTaxId *h_donor_tax_id,
-  DONAUDB_IterateSubmittedReceiptsCallback cb,
-  void *cb_cls)
+  struct TALER_Amount *total_donations)
 {
   struct PostgresClosure *pg = cls;
   struct GNUNET_PQ_QueryParam params[] = {
@@ -107,23 +41,37 @@ DH_PG_iterate_submitted_receipts (
     GNUNET_PQ_query_param_auto_from_type (&h_donor_tax_id),
     GNUNET_PQ_query_param_end
   };
-  struct IterateSubmittedReceiptsContext ctx = {
-    .cb = cb,
-    .cb_cls = cb_cls,
-    .pg = pg
+  uint64_t value;
+  uint64_t fraction;
+  struct GNUNET_PQ_ResultSpec rs[] = {
+    GNUNET_PQ_result_spec_uint64 ("value",
+                                  &value),
+    GNUNET_PQ_result_spec_uint64 ("fraction",
+                                  &fraction),
+    GNUNET_PQ_result_spec_end
   };
+  enum GNUNET_DB_QueryStatus qs;
 
   PREPARE (pg,
            "lookup_submitted_receipts",
            "SELECT "
-           " value"
+           " CAST(SUM((ref.amount_with_fee).val) AS INT8) AS value"
+           ",CAST(SUM(CAST((value.amount_with_fee).frac AS INT8)) AS INT8) AS 
fraction"
            " FROM receipts_submitted"
            " JOIN donation_units USING (donation_unit_pub)"
            " WHERE donation_year=$1"
            " AND h_tax_number=$2");
-  return GNUNET_PQ_eval_prepared_multi_select (pg->conn,
-                                               "iterate_submitted_receipts",
-                                               params,
-                                               &iterate_submitted_receipts_cb,
-                                               &ctx);
+  qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
+                                                 "iterate_submitted_receipts",
+                                                 params,
+                                                 rs);
+  if (qs < 0)
+    return qs;
+  value += fraction / TALER_AMOUNT_FRAC_BASE;
+  fraction %= TALER_AMOUNT_FRAC_BASE;
+  TALER_amount_set_zero (pg->currency,
+                         total_donations);
+  total->donations->val = value;
+  total->donations->frac = fraction;
+  return qs;
 }
diff --git a/src/include/donaudb_plugin.h b/src/include/donaudb_plugin.h
index 1d269f2..0221b84 100644
--- a/src/include/donaudb_plugin.h
+++ b/src/include/donaudb_plugin.h
@@ -544,28 +544,27 @@ struct DONAUDB_Plugin
     uint64_t donation_year);
 
   /**
-    * Iterate submitted donation receipt.
-    *
-    * @param cls closure
-    * @param value
-    * @return database transaction status
-    */
+   * Iterate submitted donation receipt.
+   *
+   * @param cls closure
+   * @param value
+   * @return database transaction status
+   */
   enum GNUNET_DB_QueryStatus
     (*iterate_submitted_receipts)(
     void *cls,
     const uint64_t donation_year,
     const struct DONAU_HashDonorTaxId *h_donor_tax_id,
-    DONAUDB_IterateSubmittedReceiptsCallback cb,
-    void *cb_cls);
+    struct TALER_Amount *total_donations);
 
   /**
-  * Lookup issued receipts from the charity.
-  *
-  * @param cls closure
-  * @param h_receipts the hash over the blinded unique identifiers
-  * @param meta meta data about an issued request
-  * @return transaction status code
-  */
+   * Lookup issued receipts from the charity.
+   *
+   * @param cls closure
+   * @param h_receipts the hash over the blinded unique identifiers
+   * @param meta meta data about an issued request
+   * @return transaction status code
+   */
   enum GNUNET_DB_QueryStatus
     (*lookup_issued_receipts)(
     void *cls,

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