1
0
mirror of https://github.com/haiwen/ccnet-server.git synced 2025-09-17 15:30:24 +00:00

Get group members add LIMIT (#53)

This commit is contained in:
feiniks
2020-10-15 15:23:27 +08:00
committed by GitHub
parent e603dfdecd
commit 908a024603
7 changed files with 39 additions and 15 deletions

View File

@@ -1020,18 +1020,35 @@ get_ccnet_groupuser_cb (CcnetDBRow *row, void *data)
}
GList *
ccnet_group_manager_get_group_members (CcnetGroupManager *mgr, int group_id,
ccnet_group_manager_get_group_members (CcnetGroupManager *mgr,
int group_id,
int start,
int limit,
GError **error)
{
CcnetDB *db = mgr->priv->db;
char *sql;
GList *group_users = NULL;
int rc;
if (limit == -1) {
sql = "SELECT group_id, user_name, is_staff FROM GroupUser WHERE group_id = ?";
rc = ccnet_db_statement_foreach_row (db, sql,
get_ccnet_groupuser_cb, &group_users,
1, "int", group_id);
} else {
sql = "SELECT group_id, user_name, is_staff FROM GroupUser WHERE group_id = ? LIMIT ? OFFSET ?";
rc = ccnet_db_statement_foreach_row (db, sql,
get_ccnet_groupuser_cb, &group_users,
3, "int", group_id,
"int", limit,
"int", start);
sql = "SELECT group_id, user_name, is_staff FROM GroupUser WHERE group_id = ?";
if (ccnet_db_statement_foreach_row (db, sql,
get_ccnet_groupuser_cb, &group_users,
1, "int", group_id) < 0)
}
if (rc < 0) {
return NULL;
}
return g_list_reverse (group_users);
}