Pledge List: Show hours because it's a more meaningful statistic.

This commit is contained in:
Ian Dunn 2019-10-31 16:23:57 -05:00
parent 7273057950
commit 33d3bc1933
No known key found for this signature in database
GPG key ID: 99B971B50343CBCB
5 changed files with 28 additions and 18 deletions

View file

@ -225,6 +225,7 @@ function filter_query( $query ) {
}
$contributor_count_key = META_PREFIX . 'pledge-confirmed-contributors';
$hours_count_key = META_PREFIX . 'pledge-total-hours';
// Set up meta queries to include the "valid pledge" check, added to both search and pledge archive requests.
$meta_queries = (array) $query->get( 'meta_query' );
@ -246,14 +247,15 @@ function filter_query( $query ) {
// Archives should only show pledges with contributors.
$query->set( 'meta_query', $meta_queries );
$order = isset( $_GET['order'] ) ? $_GET['order'] : '';
switch ( $order ) {
case 'alphabetical':
$query->set( 'orderby', 'name' );
$query->set( 'order', 'ASC' );
break;
case 'contributors':
$query->set( 'meta_key', $contributor_count_key );
case 'hours':
$query->set( 'meta_key', $hours_count_key );
$query->set( 'orderby', 'meta_value_num' );
$query->set( 'order', 'DESC' );
break;