Guest User

Untitled

a guest
Oct 22nd, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. diff --git a/bundles/dashboard/models/graphs.php b/bundles/dashboard/models/graphs.php
  2. index 255e599..182c39d 100755
  3. --- a/bundles/dashboard/models/graphs.php
  4. +++ b/bundles/dashboard/models/graphs.php
  5. @@ -199,7 +199,8 @@ class graphs {
  6. $input['numberReads'] = $this->groupBySum($input['numberReads'], 'createdAt', 'numberReads');
  7.  
  8. foreach($input['numberPublications'] as $key => $x) {
  9. - $result[$key] = (( $input['numberPublications'][$key] / $input['numberReads'][$key] ) * 100);
  10. + $numberReads = ($input['numberReads'][$key] == 0) ? 100 : $input['numberReads'][$key];
  11. + $result[$key] = (( $input['numberPublications'][$key] / $numberReads ) * 100);
  12. }
  13.  
  14. return $result;
  15.  
  16.  
  17.  
  18. /////
  19. When a research isn't readed, you have a division by 0 -> error
  20. now if a research isn't readed, i set the numberReads to 100 so the equation look like :
  21. $result = NumberPublications * 100 / 100
  22. i don't know if the calcul is right but i don't have the exception anymore :)
Add Comment
Please, Sign In to add comment