Skip to content

Commit

Permalink
Issue #15 - Report total compatible as well as analysed and show perc…
Browse files Browse the repository at this point in the history
…entage to 1 decimal place
  • Loading branch information
bobbingwide committed Mar 22, 2018
1 parent 9f14fc2 commit 0d1befe
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions admin/class-oik-block-site-summary.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function __construct() {

function report() {
$this->report_content();
$this->report_analysis();
//$this->report_analysis();
}

function report_content() {
Expand All @@ -33,6 +33,8 @@ function report_analysis() {
$total = array_sum( $counts );
$compatible = $this->compatible( $counts );
$percentage = $this->percentage( $compatible, $total );
printf( 'Compatible: %1$s', $compatible );
echo PHP_EOL;

printf( 'Percentage compatible: %1$s', $percentage );
echo PHP_EOL;
Expand All @@ -44,14 +46,15 @@ function percentage( $value, $total ) {
if ( $total ) {
$value *= 100;
$percentage = $value / $total;
$percentage = number_format( $percentage ) . __( '%', 'oik_block' );
$percentage = number_format( $percentage, 1 ) . __( '%', 'oik_block' );
} else {
$percentage = 'na';
}
return $percentage;
}

function compatible( $counts ) {
//print_r( $counts );

$compatible = bw_array_get( $counts, "AM", 0 );
$compatible += bw_array_get( $counts, "AO", 0 );
Expand All @@ -73,7 +76,7 @@ function select_counts() {
foreach ( $results as $result ) {
$counts[ $result->meta_value ] = $result->count;
}
//bw_trace2( $counts );
bw_trace2( $counts );
return $counts;
}

Expand Down

0 comments on commit 0d1befe

Please sign in to comment.