commit 6c56bb6e9d4ca638d50f4a51a92ea81a876f1be9
parent 656c959876b133f5e3309c10396a18cc7498c466
Author: Casaburi Johannes <johannes.casaburi@students.bfh.ch>
Date: Sun, 14 Jan 2024 21:31:44 +0100
added lookup history entry
Diffstat:
4 files changed, 38 insertions(+), 8 deletions(-)
diff --git a/src/donau/Makefile.am b/src/donau/Makefile.am
@@ -44,7 +44,8 @@ donau_httpd_SOURCES = \
donau-httpd_config.c donau-httpd_config.h \
donau-httpd_get-charities.c donau_httpd_charity.h \
donau-httpd_get-charity.c donau-httpd_post-charity.c \
- donau-httpd_get-history.c donau-httpd_history.h \
+ donau-httpd_get-history-entry.c donau-httpd_history.h \
+ donau-httpd_get-history.c \
donau-httpd_terms.c donau-httpd_terms.h
# Testcases
diff --git a/src/donau/donau-httpd_get-history-entry.c b/src/donau/donau-httpd_get-history-entry.c
@@ -38,7 +38,7 @@
#define MAX_RECORDS 1024
MHD_RESULT
-DH_handler_history_get (
+DH_handler_history_entry_get (
struct DH_RequestContext *rc,
const char *const args[])
{
@@ -68,13 +68,15 @@ DH_handler_history_get (
}
{
- struct DONAUDB_CharityMetaData meta;
+ const struct TALER_Amount *final_amount;
+ const uint64_t donation_year;
enum GNUNET_DB_QueryStatus qs;
MHD_RESULT result;
qs = DH_plugin->lookup_history_entry (DH_plugin->cls,
- charity_id,
- &meta);
+ charity_id,
+ &final_amount,
+ donation_year);
switch (qs)
{
case GNUNET_DB_STATUS_HARD_ERROR:
@@ -100,11 +102,11 @@ DH_handler_history_get (
rc->connection,
MHD_HTTP_OK,
TALER_JSON_pack_amount ("final_amount",
- meta.final_amount),
+ final_amount),
GNUNET_JSON_pack_uint64 ("donation_year",
- meta.donation_year));
+ donation_year));
- GNUNET_free (meta.final_amount);
+ GNUNET_free (final_amount);
return result;
}
}
diff --git a/src/donau/donau-httpd_history.h b/src/donau/donau-httpd_history.h
@@ -36,4 +36,16 @@ DH_handler_history_get (
struct DH_RequestContext *rc,
const char *const args[]);
+/**
+ * Handle a GET "/history/$charity_id" request.
+ *
+ * @param rc request context
+ * @param args GET arguments (should be one)
+ * @return MHD result code
+ */
+MHD_RESULT
+DH_handler_history_entry_get (
+ struct DH_RequestContext *rc,
+ const char *const args[]);
+
#endif
diff --git a/src/include/donaudb_plugin.h b/src/include/donaudb_plugin.h
@@ -448,6 +448,21 @@ struct DONAUDB_Plugin
void *cb_cls);
/**
+ * Lookup history entry.
+ *
+ * @param cls closure
+ * @param cb callback to invoke on each match
+ * @param cb_cls closure for @a cb
+ * @return database transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_history_entry)(
+ void *cls,
+ const uint64_t charity_id,
+ const struct TALER_Amount *final_amount,
+ const uint64_t donation_year);
+
+ /**
* Get donation_unit_key.
*
* @param cls closure