reports: Generalize dates, saved reports
[ninja.git] / modules / reports / libraries / AverageStateCalculator.php
blob8d047780c9d61ceed5206813ed6b52cee6235b38
1 <?php
3 /**
4 * State calculator for multiple objects that returns the average state
5 */
6 class AverageStateCalculator extends WorstStateCalculator
8 public function add_event($row = false)
10 foreach ($this->sub_reports as $idx => $rpt) {
11 $rpt->add_event($row);
15 public function calculate_object_state() { /* No thanks */ }
17 public function finalize()
19 foreach ($this->sub_reports as $rpt) {
20 $rpt->finalize();
23 foreach ($this->sub_reports as $rpt) {
24 foreach ($rpt->st_raw as $type => $value) {
25 $this->st_raw[$type] = (isset($this->st_raw[$type])?$this->st_raw[$type]:0) + $value;
28 $c = count($this->sub_reports);
29 foreach ($this->st_raw as $type => $val) {
30 $this->st_raw[$type] = $val / $c;