summaryrefslogtreecommitdiff
path: root/src/backenddb
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-06-21 23:52:30 +0200
committerChristian Grothoff <christian@grothoff.org>2020-06-21 23:52:30 +0200
commit5d3bfab13a189a5f8a94ccadf257a6a612e618dc (patch)
tree696f6b036c78044f057ea77ca7754744f7dc8dfa /src/backenddb
parente5c81bcae0e402877fc9b6c54f91ef9ef3267b67 (diff)
downloadmerchant-5d3bfab13a189a5f8a94ccadf257a6a612e618dc.tar.gz
merchant-5d3bfab13a189a5f8a94ccadf257a6a612e618dc.tar.bz2
merchant-5d3bfab13a189a5f8a94ccadf257a6a612e618dc.zip
add missing notifications to private-get-orders long poller
Diffstat (limited to 'src/backenddb')
-rw-r--r--src/backenddb/plugin_merchantdb_postgres.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c
index 12dc3498..e1b14792 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -1116,6 +1116,45 @@ postgres_lookup_order (void *cls,
/**
+ * Retrieve order summary given its @a order_id and the @a instance_id.
+ *
+ * @param cls closure
+ * @param instance_id instance to obtain order of
+ * @param order_id order id used to perform the lookup
+ * @param[out] timestamp when was the order created
+ * @param[out] order_serial under which serial do we keep this order
+ * @return transaction status
+ */
+static enum GNUNET_DB_QueryStatus
+postgres_lookup_order_summary (void *cls,
+ const char *instance_id,
+ const char *order_id,
+ struct GNUNET_TIME_Absolute *timestamp,
+ uint64_t *order_serial)
+{
+ struct PostgresClosure *pg = cls;
+ struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_string (instance_id),
+ GNUNET_PQ_query_param_string (order_id),
+ GNUNET_PQ_query_param_end
+ };
+ struct GNUNET_PQ_ResultSpec rs[] = {
+ GNUNET_PQ_result_spec_uint64 ("order_serial",
+ order_serial),
+ GNUNET_PQ_result_spec_absolute_time ("creation_time",
+ timestamp),
+ GNUNET_PQ_result_spec_end
+ };
+
+ check_connection (pg);
+ return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
+ "lookup_order_summary",
+ params,
+ rs);
+}
+
+
+/**
* Context used for postgres_lookup_orders().
*/
struct LookupOrdersContext
@@ -6052,6 +6091,18 @@ libtaler_plugin_merchantdb_postgres_init (void *cls)
" WHERE merchant_id=$1)"
" AND merchant_orders.order_id=$2",
2),
+ /* for postgres_lookup_order_summary() */
+ GNUNET_PQ_make_prepare ("lookup_order_summary",
+ "SELECT"
+ " creation_time"
+ ",order_serial"
+ " FROM merchant_orders"
+ " WHERE merchant_orders.merchant_serial="
+ " (SELECT merchant_serial "
+ " FROM merchant_instances"
+ " WHERE merchant_id=$1)"
+ " AND merchant_orders.order_id=$2",
+ 2),
/* for postgres_lookup_orders() */
GNUNET_PQ_make_prepare ("lookup_orders_inc",
"(SELECT"
@@ -8101,6 +8152,7 @@ libtaler_plugin_merchantdb_postgres_init (void *cls)
plugin->lock_product = &postgres_lock_product;
plugin->delete_order = &postgres_delete_order;
plugin->lookup_order = &postgres_lookup_order;
+ plugin->lookup_order_summary = &postgres_lookup_order_summary;
plugin->lookup_orders = &postgres_lookup_orders;
plugin->insert_order = &postgres_insert_order;
plugin->unlock_inventory = &postgres_unlock_inventory;