mirror of
https://github.com/haiwen/ccnet-server.git
synced 2025-05-08 15:16:19 +00:00
Add argument 'including_org' to get_top_groups().
This commit is contained in:
parent
c2a1d1c7ca
commit
fafaccf05d
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
|
@ -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"])
|
||||
|
Loading…
Reference in New Issue
Block a user