count_of_task_in_pri.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * 按优先级统计的任务数。
  4. * Count of task in pri.
  5. *
  6. * 范围:pri
  7. * 对象:task
  8. * 目的:scale
  9. * 度量名称:按优先级统计的任务数
  10. * 单位:个
  11. * 描述:按优先级统计的任务数
  12. * 定义:按优先级统计的任务数
  13. *
  14. * @copyright Copyright 2009-2025 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
  15. * @author Yanyi Cao <caoyanyi@chandao.com>
  16. * @package
  17. * @uses func
  18. * @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  19. * @Link https://www.zentao.net
  20. */
  21. class count_of_task_in_pri extends baseCalc
  22. {
  23. public $dataset = '';
  24. public $fieldList = array();
  25. public $result = array();
  26. public function calculate($row)
  27. {
  28. if(!isset($this->result[$row->pri])) $this->result[$row->pri] = array();
  29. $this->result[$row->pri][$row->id] = $row->id;
  30. }
  31. public function getResult($options = array())
  32. {
  33. foreach($this->result as $pri => $tasks)
  34. {
  35. if(!is_array($tasks)) continue;
  36. $this->result[$pri] = count($tasks);
  37. }
  38. $records = $this->getRecords(array('pri', 'value'));
  39. return $this->filterByOptions($records, $options);
  40. }
  41. }