gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] branch master updated: add minimum age to products


From: gnunet
Subject: [taler-merchant] branch master updated: add minimum age to products
Date: Tue, 18 Jan 2022 16:26:35 +0100

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

grothoff pushed a commit to branch master
in repository merchant.

The following commit(s) were added to refs/heads/master by this push:
     new 9a86e1f1 add minimum age to products
9a86e1f1 is described below

commit 9a86e1f1e10338bf869944b2fb215a53aa1fcc54
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Tue Jan 18 16:26:33 2022 +0100

    add minimum age to products
---
 .../taler-merchant-httpd_private-get-products-ID.c       |  4 +++-
 .../taler-merchant-httpd_private-patch-products-ID.c     |  5 ++++-
 src/backend/taler-merchant-httpd_private-post-products.c |  4 ++++
 src/backenddb/merchant-0003.sql                          |  7 +++++++
 src/backenddb/plugin_merchantdb_postgres.c               | 16 ++++++++++++----
 src/include/taler_merchantdb_plugin.h                    |  7 +++++++
 6 files changed, 37 insertions(+), 6 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_private-get-products-ID.c 
b/src/backend/taler-merchant-httpd_private-get-products-ID.c
index 1cff0deb..1406349f 100644
--- a/src/backend/taler-merchant-httpd_private-get-products-ID.c
+++ b/src/backend/taler-merchant-httpd_private-get-products-ID.c
@@ -90,7 +90,9 @@ TMH_private_get_products_ID (const struct TMH_RequestHandler 
*rh,
                                      pd.address),
       GNUNET_JSON_pack_allow_null (
         GNUNET_JSON_pack_timestamp ("next_restock",
-                                   (pd.next_restock))));
+                                    (pd.next_restock))),
+      GNUNET_JSON_pack_uint64 ("minimum_age",
+                               pd.minimum_age));
     GNUNET_free (pd.description);
     GNUNET_free (pd.image);
     GNUNET_free (pd.unit);
diff --git a/src/backend/taler-merchant-httpd_private-patch-products-ID.c 
b/src/backend/taler-merchant-httpd_private-patch-products-ID.c
index 13a5c664..06e9e7be 100644
--- a/src/backend/taler-merchant-httpd_private-patch-products-ID.c
+++ b/src/backend/taler-merchant-httpd_private-patch-products-ID.c
@@ -143,7 +143,10 @@ TMH_private_patch_products_ID (const struct 
TMH_RequestHandler *rh,
                              &pd.address)),
     GNUNET_JSON_spec_mark_optional (
       GNUNET_JSON_spec_timestamp ("next_restock",
-                                     &pd.next_restock)),
+                                  &pd.next_restock)),
+    GNUNET_JSON_spec_mark_optional (
+      GNUNET_JSON_spec_uint32 ("minimum_age",
+                               &pd.minimum_age)),
     GNUNET_JSON_spec_end ()
   };
 
diff --git a/src/backend/taler-merchant-httpd_private-post-products.c 
b/src/backend/taler-merchant-httpd_private-post-products.c
index b8256a80..18a38d83 100644
--- a/src/backend/taler-merchant-httpd_private-post-products.c
+++ b/src/backend/taler-merchant-httpd_private-post-products.c
@@ -61,6 +61,7 @@ products_equal (const struct TALER_MERCHANTDB_ProductDetails 
*p1,
            (p1->total_stock == p2->total_stock) &&
            (p1->total_sold == p2->total_sold) &&
            (p1->total_lost == p2->total_lost) &&
+           (p1->minimum_age == p2->minimum_age) &&
            (0 == strcmp (p1->image,
                          p2->image)) &&
            (1 == json_equal (p1->address,
@@ -108,6 +109,9 @@ TMH_private_post_products (const struct TMH_RequestHandler 
*rh,
     GNUNET_JSON_spec_mark_optional (
       GNUNET_JSON_spec_timestamp ("next_restock",
                                   &pd.next_restock)),
+    GNUNET_JSON_spec_mark_optional (
+      GNUNET_JSON_spec_uint32 ("minimum_age",
+                               &pd.minimum_age)),
     GNUNET_JSON_spec_end ()
   };
 
diff --git a/src/backenddb/merchant-0003.sql b/src/backenddb/merchant-0003.sql
index 80860d23..370af625 100644
--- a/src/backenddb/merchant-0003.sql
+++ b/src/backenddb/merchant-0003.sql
@@ -54,5 +54,12 @@ COMMENT ON COLUMN merchant_kyc.exchange_url
   IS 'Which exchange base URL is this KYC status valid for';
 
 
+-- add age restriction column to product
+ALTER TABLE merchant_inventory
+  ADD COLUMN minimum_age INT4 NOT NULL DEFAULT 0;
+COMMENT ON COLUMN merchant_inventory.minimum_age
+  IS 'Minimum age of the customer in years, to be used if an exchange supports 
the age restriction extension.';
+
+
 -- Complete transaction
 COMMIT;
diff --git a/src/backenddb/plugin_merchantdb_postgres.c 
b/src/backenddb/plugin_merchantdb_postgres.c
index 5465b4e8..7aad3c7c 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -1364,6 +1364,8 @@ postgres_lookup_product (void *cls,
                                  &pd->address),
       GNUNET_PQ_result_spec_timestamp ("next_restock",
                                        &pd->next_restock),
+      GNUNET_PQ_result_spec_uint32 ("minimum_age",
+                                    &pd->minimum_age),
       GNUNET_PQ_result_spec_end
     };
 
@@ -1433,6 +1435,7 @@ postgres_insert_product (void *cls,
     GNUNET_PQ_query_param_uint64 (&pd->total_stock),
     TALER_PQ_query_param_json (pd->address),
     GNUNET_PQ_query_param_timestamp (&pd->next_restock),
+    GNUNET_PQ_query_param_uint32 (&pd->minimum_age),
     GNUNET_PQ_query_param_end
   };
 
@@ -1482,6 +1485,7 @@ postgres_update_product (void *cls,
     GNUNET_PQ_query_param_uint64 (&pd->total_lost),
     TALER_PQ_query_param_json (pd->address),
     GNUNET_PQ_query_param_timestamp (&pd->next_restock),
+    GNUNET_PQ_query_param_uint32 (&pd->minimum_age),
     GNUNET_PQ_query_param_end
   };
 
@@ -6993,6 +6997,7 @@ postgres_connect (void *cls)
                             ",image"
                             ",merchant_inventory.address"
                             ",next_restock"
+                            ",minimum_age"
                             " FROM merchant_inventory"
                             " JOIN merchant_instances"
                             "   USING (merchant_serial)"
@@ -7027,12 +7032,14 @@ postgres_connect (void *cls)
                             ",price_frac"
                             ",total_stock"
                             ",address"
-                            ",next_restock)"
+                            ",next_restock"
+                            ",minimum_age"
+                            ")"
                             " SELECT merchant_serial,"
-                            " $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12"
+                            " $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, 
$13"
                             " FROM merchant_instances"
                             " WHERE merchant_id=$1",
-                            12),
+                            13),
     /* for postgres_update_product() */
     GNUNET_PQ_make_prepare ("update_product",
                             "UPDATE merchant_inventory SET"
@@ -7047,6 +7054,7 @@ postgres_connect (void *cls)
                             ",total_lost=$11"
                             ",address=$12"
                             ",next_restock=$13"
+                            ",minimum_age=$14"
                             " WHERE merchant_serial="
                             "   (SELECT merchant_serial"
                             "      FROM merchant_instances"
@@ -7054,7 +7062,7 @@ postgres_connect (void *cls)
                             "   AND product_id=$2"
                             "   AND total_stock <= $10"
                             "   AND total_lost <= $11",
-                            13),
+                            14),
 
     /* for postgres_lock_product() */
     GNUNET_PQ_make_prepare ("lock_product",
diff --git a/src/include/taler_merchantdb_plugin.h 
b/src/include/taler_merchantdb_plugin.h
index d301eeef..7f120aba 100644
--- a/src/include/taler_merchantdb_plugin.h
+++ b/src/include/taler_merchantdb_plugin.h
@@ -278,6 +278,13 @@ struct TALER_MERCHANTDB_ProductDetails
    * #GNUNET_TIME_UNIT_FOREVER_ABS for never.
    */
   struct GNUNET_TIME_Timestamp next_restock;
+
+  /**
+   * Minimum required age for consumers buying this product.
+   * Default is 0. Only enforced of an exchange supports age
+   * restrictions.
+   */
+  uint32_t minimum_age;
 };
 
 

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