partial #2252 - Historical Churn and Historical Churn Rate

This commit is contained in:
pererinha 2013-12-26 12:29:34 -02:00
parent a5992bd960
commit df5f91ff86

View File

@ -45,7 +45,7 @@ class Crunchbutton_Chart_Churn extends Crunchbutton_Chart {
$daysForward = $this->activeUsersInterval; $daysForward = $this->activeUsersInterval;
$activeUsers = $user->activeByDay(); $activeUsers = $user->activeByDay();
$newUsers = $user->newByDay(); $newUsers = $user->newByDay();
$activeToday = $this->activeFromLastDays(); $activeLastDays = $this->activeFromLastDays();
$data = []; $data = [];
for( $i = 0; $i < sizeof( $activeUsers ); $i++ ){ for( $i = 0; $i < sizeof( $activeUsers ); $i++ ){
@ -53,13 +53,13 @@ class Crunchbutton_Chart_Churn extends Crunchbutton_Chart {
$activeForwardDaysPlusOne = $activeUsers[ ( $i + $daysForward + 1 ) ]->Total; $activeForwardDaysPlusOne = $activeUsers[ ( $i + $daysForward + 1 ) ]->Total;
$newForwardDays = $newUsers[ ( $i + $daysForward ) ]->Total; $newForwardDays = $newUsers[ ( $i + $daysForward ) ]->Total;
$newForwardDaysPlusOne = $newUsers[ ( $i + $daysForward + 1 ) ]->Total; $newForwardDaysPlusOne = $newUsers[ ( $i + $daysForward + 1 ) ]->Total;
$churn = ( ( $activeForwardDaysPlusOne + $newForwardDaysPlusOne ) - $activeForwardDaysPlusOne ) / $activeToday; $churn = ( ( $activeForwardDaysPlusOne + $newForwardDaysPlusOne ) - $activeForwardDaysPlusOne ) / $activeLastDays;
// Do not show the negatives // Do not show the negatives
// $churn = ( $churn < 0 ) ? 0 : $churn; $churn = ( $churn < 0 ) ? 0 : $churn;
$data[] = ( object ) array( 'Label' => $activeUsers[ $i ]->Label, 'Total' => $churn, 'Type' => 'Users' ); $data[] = ( object ) array( 'Label' => $activeUsers[ $i ]->Label, 'Total' => $churn, 'Type' => 'Users' );
} }
if( $render ){ if( $render ){
return array( 'data' => $data, 'unit' => '%', 'interval' => 'day' ); return array( 'data' => $data, 'unit' => $this->unit, 'interval' => 'day' );
} }
return $data; return $data;
} }