diff --git a/net/common/rpc-service.c b/net/common/rpc-service.c index e5fd054..f0ca77d 100644 --- a/net/common/rpc-service.c +++ b/net/common/rpc-service.c @@ -291,7 +291,7 @@ ccnet_start_rpc(CcnetSession *session) searpc_server_register_function ("ccnet-threaded-rpcserver", ccnet_rpc_get_top_groups, "get_top_groups", - searpc_signature_objlist__void()); + searpc_signature_objlist__int()); searpc_server_register_function ("ccnet-threaded-rpcserver", ccnet_rpc_get_child_groups, "get_child_groups", @@ -836,13 +836,13 @@ ccnet_rpc_search_groups (const char *group_patt, } GList* -ccnet_rpc_get_top_groups (GError **error) +ccnet_rpc_get_top_groups (int including_org, GError **error) { CcnetGroupManager *group_mgr = ((CcnetServerSession *)session)->group_mgr; GList *groups = NULL; - groups = ccnet_group_manager_get_top_groups (group_mgr, error); + groups = ccnet_group_manager_get_top_groups (group_mgr, including_org ? TRUE : FALSE, error); return groups; } diff --git a/net/common/rpc-service.h b/net/common/rpc-service.h index 334cbf7..a8d4897 100644 --- a/net/common/rpc-service.h +++ b/net/common/rpc-service.h @@ -222,7 +222,7 @@ GList * ccnet_rpc_get_ancestor_groups (int group_id, GError **error); GList * -ccnet_rpc_get_top_groups (GError **error); +ccnet_rpc_get_top_groups (int including_org, GError **error); GList * ccnet_rpc_get_child_groups (int group_id, GError **error); diff --git a/net/server/group-mgr.c b/net/server/group-mgr.c index 0259ccb..207c667 100644 --- a/net/server/group-mgr.c +++ b/net/server/group-mgr.c @@ -1148,6 +1148,7 @@ get_all_ccnetgroups_cb (CcnetDBRow *row, void *data) GList * ccnet_group_manager_get_top_groups (CcnetGroupManager *mgr, + gboolean including_org, GError **error) { CcnetDB *db = mgr->priv->db; @@ -1156,14 +1157,27 @@ ccnet_group_manager_get_top_groups (CcnetGroupManager *mgr, const char *table_name = mgr->priv->table_name; int rc; - if (ccnet_db_type(mgr->priv->db) == CCNET_DB_TYPE_PGSQL) - g_string_printf (sql, "SELECT group_id, group_name, " - "creator_name, timestamp, parent_group_id FROM \"%s\" " - "WHERE parent_group_id=-1 ORDER BY timestamp DESC", table_name); - else - g_string_printf (sql, "SELECT group_id, group_name, " - "creator_name, timestamp, parent_group_id FROM `%s` " - "WHERE parent_group_id=-1 ORDER BY timestamp DESC", table_name); + if (ccnet_db_type(mgr->priv->db) == CCNET_DB_TYPE_PGSQL) { + if (including_org) + g_string_printf (sql, "SELECT group_id, group_name, " + "creator_name, timestamp, parent_group_id FROM \"%s\" " + "WHERE parent_group_id=-1 ORDER BY timestamp DESC", table_name); + else + g_string_printf (sql, "SELECT group_id, group_name, " + "creator_name, timestamp, parent_group_id FROM \"%s\" " + "WHERE parent_group_id=-1 AND group_id NOT IN " + "(SELECT group_id FROM OrgGroup) ORDER BY timestamp DESC", table_name); + } else { + if (including_org) + g_string_printf (sql, "SELECT group_id, group_name, " + "creator_name, timestamp, parent_group_id FROM `%s` " + "WHERE parent_group_id=-1 ORDER BY timestamp DESC", table_name); + else + g_string_printf (sql, "SELECT group_id, group_name, " + "creator_name, timestamp, parent_group_id FROM `%s` " + "WHERE parent_group_id=-1 AND group_id NOT IN " + "(SELECT group_id FROM OrgGroup) ORDER BY timestamp DESC", table_name); + } rc = ccnet_db_statement_foreach_row (db, sql->str, get_all_ccnetgroups_cb, &ret, 0); g_string_free (sql, TRUE); diff --git a/net/server/group-mgr.h b/net/server/group-mgr.h index f03f90f..64e2078 100644 --- a/net/server/group-mgr.h +++ b/net/server/group-mgr.h @@ -125,7 +125,7 @@ ccnet_group_manager_search_groups (CcnetGroupManager *mgr, int start, int limit); GList * -ccnet_group_manager_get_top_groups (CcnetGroupManager *mgr, GError **error); +ccnet_group_manager_get_top_groups (CcnetGroupManager *mgr, gboolean including_org, GError **error); GList * ccnet_group_manager_get_child_groups (CcnetGroupManager *mgr, int group_id, diff --git a/python/ccnet/rpc.py b/python/ccnet/rpc.py index fe87b90..4722d16 100644 --- a/python/ccnet/rpc.py +++ b/python/ccnet/rpc.py @@ -307,8 +307,8 @@ class CcnetThreadedRpcClient(RpcClientBase): def get_ancestor_groups(self, group_id): pass - @searpc_func("objlist", []) - def get_top_groups(self): + @searpc_func("objlist", ["int"]) + def get_top_groups(self, including_org): pass @searpc_func("objlist", ["int"])