diff --git a/CHANGELOG.md b/CHANGELOG.md index cba08f6fa..537bae137 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Update result diff generation at delta reports [#650](https://github.com/greenbone/gvmd/pull/650) - Check and create default permissions individually [#671](https://github.com/greenbone/gvmd/pull/671) - Add -f arg to sendmail call in email alert [#676](https://github.com/greenbone/gvmd/pull/676) [#678](https://github.com/greenbone/gvmd/pull/678) +- Change get_tickets to use the status text for filtering. [#697](https://github.com/greenbone/gvmd/pull/697) ### Fixed - A PostgreSQL statement order issue [#611](https://github.com/greenbone/gvmd/issues/611) has been addressed [#642](https://github.com/greenbone/gvmd/pull/642) diff --git a/src/manage_sql_tickets.c b/src/manage_sql_tickets.c index d66f11a42..e2802a451 100644 --- a/src/manage_sql_tickets.c +++ b/src/manage_sql_tickets.c @@ -79,31 +79,6 @@ ticket_status_integer (const char *status) return TICKET_STATUS_ERROR; } -/** - * @brief Get ticket status name from DB identifier. - * - * @param[in] status Status integer. - * - * @return Status name. - */ -static const gchar * -ticket_status_name (ticket_status_t status) -{ - switch (status) - { - case TICKET_STATUS_OPEN: - return "Open"; - case TICKET_STATUS_FIXED: - return "Fixed"; - case TICKET_STATUS_FIX_VERIFIED: - return "Fix Verified"; - case TICKET_STATUS_CLOSED: - return "Closed"; - default: - return "Error"; - } -} - /** * @brief Filter columns for ticket iterator. */ @@ -157,7 +132,14 @@ ticket_status_name (ticket_status_t status) { "host", NULL, KEYWORD_TYPE_STRING }, \ { "location", NULL, KEYWORD_TYPE_STRING }, \ { "solution_type", NULL, KEYWORD_TYPE_STRING }, \ - { "status", NULL, KEYWORD_TYPE_STRING }, \ + { "(CASE status" \ + " WHEN 0 THEN 'Open'" \ + " WHEN 1 THEN 'Fixed'" \ + " WHEN 2 THEN 'Fix Verified'" \ + " WHEN 3 THEN 'Closed'" \ + " ELSE 'Error' END)", \ + "status", \ + KEYWORD_TYPE_STRING }, \ { "iso_time (open_time)", NULL, KEYWORD_TYPE_STRING }, \ { "open_time", "opened", KEYWORD_TYPE_INTEGER }, \ { "iso_time (fixed_time)", NULL, KEYWORD_TYPE_STRING }, \ @@ -226,7 +208,14 @@ ticket_status_name (ticket_status_t status) { "host", NULL, KEYWORD_TYPE_STRING }, \ { "location", NULL, KEYWORD_TYPE_STRING }, \ { "solution_type", NULL, KEYWORD_TYPE_STRING }, \ - { "status", NULL, KEYWORD_TYPE_STRING }, \ + { "(CASE status" \ + " WHEN 0 THEN 'Open'" \ + " WHEN 1 THEN 'Fixed'" \ + " WHEN 2 THEN 'Fix Verified'" \ + " WHEN 3 THEN 'Closed'" \ + " ELSE 'Error' END)", \ + "status", \ + KEYWORD_TYPE_STRING }, \ { "iso_time (open_time)", NULL, KEYWORD_TYPE_STRING }, \ { "open_time", "opened", KEYWORD_TYPE_INTEGER }, \ { "iso_time (fixed_time)", NULL, KEYWORD_TYPE_STRING }, \ @@ -391,14 +380,7 @@ DEF_ACCESS (ticket_iterator_solution_type, GET_ITERATOR_COLUMN_COUNT + 6); * * @return Status of the ticket or NULL if iteration is complete. */ -const char* -ticket_iterator_status (iterator_t* iterator) -{ - int status; - if (iterator->done) return NULL; - status = iterator_int (iterator, GET_ITERATOR_COLUMN_COUNT + 7); - return ticket_status_name (status); -} +DEF_ACCESS (ticket_iterator_status, GET_ITERATOR_COLUMN_COUNT + 7); /** * @brief Get column value from a ticket iterator.