Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use status text in ticket iterator columns #697

Merged
merged 3 commits into from
Aug 15, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,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)
Expand Down
52 changes: 17 additions & 35 deletions src/manage_sql_tickets.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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'" \
mattmundell marked this conversation as resolved.
Show resolved Hide resolved
" 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 }, \
Expand Down Expand Up @@ -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 }, \
Expand Down Expand Up @@ -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.
Expand Down