LCOV - code coverage report
Current view: top level - backenddb - insert_donau_keys.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 91.7 % 12 11
Test Date: 2026-09-04 23:42:01 Functions: 100.0 % 1 1

            Line data    Source code
       1              : /*
       2              :    This file is part of TALER
       3              :    Copyright (C) 2024 Taler Systems SA
       4              : 
       5              :    TALER is free software; you can redistribute it and/or modify it under the
       6              :    terms of the GNU General Public License as published by the Free Software
       7              :    Foundation; either version 3, or (at your option) any later version.
       8              : 
       9              :    TALER is distributed in the hope that it will be useful, but WITHOUT ANY
      10              :    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
      11              :    A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
      12              : 
      13              :    You should have received a copy of the GNU General Public License along with
      14              :    TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
      15              :  */
      16              : /**
      17              :  * @file src/backenddb/insert_donau_keys.c
      18              :  * @brief Implementation of the insert_donau_keys function for Postgres
      19              :  * @author Bohdan Potuzhnyi
      20              :  * @author Vlada Svirsh
      21              :  */
      22              : #include "platform.h"
      23              : #include <taler/taler_pq_lib.h>
      24              : #include "donau/donau_service.h"
      25              : #include "merchant-database/insert_donau_keys.h"
      26              : #include "helper.h"
      27              : 
      28              : 
      29              : enum GNUNET_DB_QueryStatus
      30            2 : TALER_MERCHANTDB_insert_donau_keys (
      31              :   struct TALER_MERCHANTDB_PostgresContext *pg,
      32              :   const struct DONAU_Keys *keys,
      33              :   struct GNUNET_TIME_Absolute first_retry)
      34              : {
      35              :   enum GNUNET_DB_QueryStatus qs;
      36            2 :   json_t *jkeys = DONAU_keys_to_json (keys);
      37              : 
      38            2 :   if (NULL == jkeys)
      39            0 :     return GNUNET_DB_STATUS_HARD_ERROR;
      40              : 
      41              :   {
      42            2 :     struct GNUNET_PQ_QueryParam params[] = {
      43            2 :       TALER_PQ_query_param_json (jkeys),
      44            2 :       GNUNET_PQ_query_param_absolute_time (&first_retry),
      45            2 :       GNUNET_PQ_query_param_string (keys->donau_url),
      46              :       GNUNET_PQ_query_param_end
      47              :     };
      48              : 
      49            2 :     PREPARE (pg,
      50              :              "insert_donau_keys",
      51              :              "INSERT INTO merchant.merchant_donau_keys"
      52              :              "  (keys_json"
      53              :              "  ,first_retry"
      54              :              "  ,donau_url"
      55              :              "  ) VALUES ("
      56              :              "   $1::TEXT::JSONB"
      57              :              "  ,$2"
      58              :              "  ,$3)"
      59              :              "  ON CONFLICT (donau_url)"
      60              :              " DO UPDATE SET"
      61              :              "  keys_json=EXCLUDED.keys_json,"
      62              :              "  first_retry=EXCLUDED.first_retry;");
      63            2 :     qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
      64              :                                              "insert_donau_keys",
      65              :                                              params);
      66              :   }
      67              : 
      68            2 :   json_decref (jkeys);
      69            2 :   return qs;
      70              : }
        

Generated by: LCOV version 2.0-1