From 0ad31bb0005f1b917b652710d51aabf63f9db834 Mon Sep 17 00:00:00 2001 From: tudacs Date: Thu, 14 Sep 2023 07:25:51 +0200 Subject: [PATCH] Add additional output to QSO-API call Two return fields added for improved reporting: - Messages returned from Logbook-import - Number of QSO's added without message --- application/controllers/Api.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/application/controllers/Api.php b/application/controllers/Api.php index 1230ff20..447efd67 100644 --- a/application/controllers/Api.php +++ b/application/controllers/Api.php @@ -164,6 +164,9 @@ class API extends CI_Controller { $this->load->model('stations'); + $return_msg = array(); + $return_count = 0; + // Decode JSON and store $obj = json_decode(file_get_contents("php://input"), true); if ($obj === NULL) { @@ -213,12 +216,18 @@ class API extends CI_Controller { $this->api_model->update_last_used($obj['key']); - $this->logbook_model->import($record, $obj['station_profile_id'], NULL, NULL, NULL, NULL, NULL, NULL, false, false, true); + $msg = $this->logbook_model->import($record, $obj['station_profile_id'], NULL, NULL, NULL, NULL, NULL, NULL, false, false, true); + + if ( $msg == "" ) { + $return_count++; + } else { + $return_msg[] = $msg; + } } }; http_response_code(201); - echo json_encode(['status' => 'created', 'type' => $obj['type'], 'string' => $obj['string']]); + echo json_encode(['status' => 'created', 'type' => $obj['type'], 'string' => $obj['string'], 'created' => $return_count, 'messages' => $return_msg ]); }