1
0
mirror of https://github.com/haiwen/ccnet-server.git synced 2025-06-03 11:09:25 +00:00

Add argument 'including_org' to get_top_groups().

This commit is contained in:
cuihaikuo 2018-08-17 15:17:29 +08:00
parent c2a1d1c7ca
commit fafaccf05d
5 changed files with 29 additions and 15 deletions

View File

@ -291,7 +291,7 @@ ccnet_start_rpc(CcnetSession *session)
searpc_server_register_function ("ccnet-threaded-rpcserver", searpc_server_register_function ("ccnet-threaded-rpcserver",
ccnet_rpc_get_top_groups, ccnet_rpc_get_top_groups,
"get_top_groups", "get_top_groups",
searpc_signature_objlist__void()); searpc_signature_objlist__int());
searpc_server_register_function ("ccnet-threaded-rpcserver", searpc_server_register_function ("ccnet-threaded-rpcserver",
ccnet_rpc_get_child_groups, ccnet_rpc_get_child_groups,
"get_child_groups", "get_child_groups",
@ -836,13 +836,13 @@ ccnet_rpc_search_groups (const char *group_patt,
} }
GList* GList*
ccnet_rpc_get_top_groups (GError **error) ccnet_rpc_get_top_groups (int including_org, GError **error)
{ {
CcnetGroupManager *group_mgr = CcnetGroupManager *group_mgr =
((CcnetServerSession *)session)->group_mgr; ((CcnetServerSession *)session)->group_mgr;
GList *groups = NULL; 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; return groups;
} }

View File

@ -222,7 +222,7 @@ GList *
ccnet_rpc_get_ancestor_groups (int group_id, GError **error); ccnet_rpc_get_ancestor_groups (int group_id, GError **error);
GList * GList *
ccnet_rpc_get_top_groups (GError **error); ccnet_rpc_get_top_groups (int including_org, GError **error);
GList * GList *
ccnet_rpc_get_child_groups (int group_id, GError **error); ccnet_rpc_get_child_groups (int group_id, GError **error);

View File

@ -1148,6 +1148,7 @@ get_all_ccnetgroups_cb (CcnetDBRow *row, void *data)
GList * GList *
ccnet_group_manager_get_top_groups (CcnetGroupManager *mgr, ccnet_group_manager_get_top_groups (CcnetGroupManager *mgr,
gboolean including_org,
GError **error) GError **error)
{ {
CcnetDB *db = mgr->priv->db; 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; const char *table_name = mgr->priv->table_name;
int rc; int rc;
if (ccnet_db_type(mgr->priv->db) == CCNET_DB_TYPE_PGSQL) if (ccnet_db_type(mgr->priv->db) == CCNET_DB_TYPE_PGSQL) {
g_string_printf (sql, "SELECT group_id, group_name, " if (including_org)
"creator_name, timestamp, parent_group_id FROM \"%s\" " g_string_printf (sql, "SELECT group_id, group_name, "
"WHERE parent_group_id=-1 ORDER BY timestamp DESC", table_name); "creator_name, timestamp, parent_group_id FROM \"%s\" "
else "WHERE parent_group_id=-1 ORDER BY timestamp DESC", table_name);
g_string_printf (sql, "SELECT group_id, group_name, " else
"creator_name, timestamp, parent_group_id FROM `%s` " g_string_printf (sql, "SELECT group_id, group_name, "
"WHERE parent_group_id=-1 ORDER BY timestamp DESC", table_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, rc = ccnet_db_statement_foreach_row (db, sql->str,
get_all_ccnetgroups_cb, &ret, 0); get_all_ccnetgroups_cb, &ret, 0);
g_string_free (sql, TRUE); g_string_free (sql, TRUE);

View File

@ -125,7 +125,7 @@ ccnet_group_manager_search_groups (CcnetGroupManager *mgr,
int start, int limit); int start, int limit);
GList * 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 * GList *
ccnet_group_manager_get_child_groups (CcnetGroupManager *mgr, int group_id, ccnet_group_manager_get_child_groups (CcnetGroupManager *mgr, int group_id,

View File

@ -307,8 +307,8 @@ class CcnetThreadedRpcClient(RpcClientBase):
def get_ancestor_groups(self, group_id): def get_ancestor_groups(self, group_id):
pass pass
@searpc_func("objlist", []) @searpc_func("objlist", ["int"])
def get_top_groups(self): def get_top_groups(self, including_org):
pass pass
@searpc_func("objlist", ["int"]) @searpc_func("objlist", ["int"])