fix(web/group): group rank list pagination

This commit is contained in:
Baoshuo Ren 2022-10-22 09:29:51 +08:00
parent bee296a1d9
commit ee6169f621
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
3 changed files with 7 additions and 2 deletions

View File

@ -143,6 +143,7 @@ EOD,
'page_len' => 50,
'group_id' => $group_id,
'by_accepted' => true,
'div_classes' => ['table-responsive', 'mb-3'],
'table_classes' => ['table', 'text-center', 'mb-0'],
]) ?>
</div>

View File

@ -1389,10 +1389,13 @@ function echoRanklist($config = array()) {
$col_names = array('b.username as username', 'count(*) as ac_num', 'b.motto as motto');
$cond = '1';
$tail = 'group by username order by ac_num desc, username asc';
$config['pagination_table'] = 'user_info';
if (isset($config['group_id'])) {
$group_id = $config['group_id'];
$from = "best_ac_submissions a inner join user_info b on a.submitter = b.username inner join groups_users c on (a.submitter = c.username and c.group_id = {$group_id})";
$config['pagination_table'] = 'groups_users';
$config['pagination_cond'] = "group_id = {$group_id}";
}
if (isset($config['top10'])) {
@ -1400,6 +1403,5 @@ function echoRanklist($config = array()) {
}
$config['get_row_index'] = '';
$config['pagination_table'] = 'user_info';
echoLongTable($col_names, $from, $cond, $tail, $header_row, $print_row, $config);
}

View File

@ -17,10 +17,12 @@ class Paginator {
$this->table = $config['data'];
} elseif (!isset($config['echo_full'])) {
$table = $config['table_name'];
$cond = isset($config['cond']) ? $config['cond'] : '1';
if (isset($config['pagination_table'])) {
$table = $config['pagination_table'];
$cond = isset($config['pagination_cond']) ? $config['pagination_cond'] : $cond;
}
$this->n_rows = DB::selectCount("select count(*) from {$table} where {$config['cond']}");
$this->n_rows = DB::selectCount("select count(*) from {$table} where {$cond}");
$this->page_len = isset($config['page_len']) ? $config['page_len'] : 10;