Skip to content

Commit

Permalink
Outsourced the SQL query for the community appliance value.
Browse files Browse the repository at this point in the history
Outsourced the SQL query for the community appliance value from
manage_license.c to manage_sql.c.
  • Loading branch information
jhelmold committed Feb 24, 2022
1 parent c1ef285 commit 6812ea1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/manage_license.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "manage_acl.h"
#include "manage_license.h"
#include "utils.h"
#include "sql.h"
#include "manage_sql.h"

#undef G_LOG_DOMAIN
/**
Expand Down Expand Up @@ -182,8 +182,7 @@ get_appliance_status(theia_got_license_info_t *gli)
gchar *comm_app;
gchar *app_status;

comm_app = sql_string ("SELECT value from public.meta"
" where name = 'community_appliance';");
comm_app = get_community_appliance_value ();

if (comm_app && atoi (comm_app))
app_status = g_strdup("community");
Expand Down
12 changes: 12 additions & 0 deletions src/manage_sql.c
Original file line number Diff line number Diff line change
Expand Up @@ -55493,6 +55493,18 @@ delete_permissions_cache_for_user (user_t user)
sql ("DELETE FROM permissions_get_tasks WHERE \"user\" = %llu;", user);
}

/**
* @brief Get the community appliance value
*
* @return community appliance value or NULL if not available or on error
*/
gchar *
get_community_appliance_value ()
{
return (sql_string ("SELECT value from public.meta"
" where name = 'community_appliance';"));
}


/* Optimize. */

Expand Down
4 changes: 4 additions & 0 deletions src/manage_sql.h
Original file line number Diff line number Diff line change
Expand Up @@ -480,4 +480,8 @@ config_family_entire_and_growing (config_t, const char*);
void
reports_clear_count_cache_dynamic ();


gchar *
get_community_appliance_value ();

#endif /* not _GVMD_MANAGE_SQL_H */

0 comments on commit 6812ea1

Please sign in to comment.