Calculate subset results

This commit is contained in:
Brian Miyaji
2015-09-17 17:06:26 +10:00
parent af7dea5ac0
commit cb2bd663e1
3 changed files with 42 additions and 8 deletions

View File

@@ -163,7 +163,7 @@ class SP_League_Table extends SP_Custom_Post{
'numberposts' => -1,
'posts_per_page' => -1,
'orderby' => 'post_date',
'order' => 'DESC',
'order' => 'ASC',
'meta_query' => array(
array(
'key' => 'sp_format',
@@ -196,6 +196,8 @@ class SP_League_Table extends SP_Custom_Post{
$events = get_posts( $args );
$e = 0;
// Event loop
foreach ( $events as $event ):
@@ -265,9 +267,11 @@ class SP_League_Table extends SP_Custom_Post{
else:
if ( array_key_exists( $team_id, $totals ) && is_array( $totals[ $team_id ] ) && array_key_exists( $key . 'for', $totals[ $team_id ] ) ):
$totals[ $team_id ][ $key . 'for' ] += $value;
$totals[ $team_id ][ $key . 'for' . ( $e + 1 ) ] = $value;
foreach( $results as $other_team_id => $other_result ):
if ( $other_team_id != $team_id && array_key_exists( $key . 'against', $totals[ $team_id ] ) ):
$totals[ $team_id ][ $key . 'against' ] += sp_array_value( $other_result, $key, 0 );
$totals[ $team_id ][ $key . 'against' . ( $e + 1 ) ] = sp_array_value( $other_result, $key, 0 );
endif;
endforeach;
endif;
@@ -279,6 +283,8 @@ class SP_League_Table extends SP_Custom_Post{
endforeach;
$e++;
endforeach;
foreach ( $streaks as $team_id => $streak ):