count_of_monthly_created_project.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * 按系统统计的月度新增项目数。
  4. * Count of monthly created project.
  5. *
  6. * 范围:system
  7. * 对象:project
  8. * 目的:scale
  9. * 度量名称:按系统统计的月度新增项目数
  10. * 单位:个
  11. * 描述:按系统统计的月度新增项目数是指在某月度新创建的项目数量。这个度量项可以帮助团队了解某年度项目规模和工作负荷,以及项目管理和资源分配的需求。较高的年度新增项目数可能需要团队根据资源和能力进行优先级和规划管理。
  12. * 定义:所有的项目个数求和;创建时间为某年某月;过滤已删除的项目;
  13. *
  14. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
  15. * @author zhouxin <zhouxin@easycorp.ltd>
  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_monthly_created_project extends baseCalc
  22. {
  23. public $dataset = 'getAllProjects';
  24. public $fieldList = array('t1.openedDate');
  25. public $result = array();
  26. public function calculate($row)
  27. {
  28. $year = $this->getYear($row->openedDate);
  29. if(!$year) return false;
  30. $month = substr($row->openedDate, 5, 2);
  31. if(!isset($this->result[$year])) $this->result[$year] = array();
  32. if(!isset($this->result[$year][$month])) $this->result[$year][$month] = 0;
  33. $this->result[$year][$month] += 1;
  34. }
  35. public function getResult($options = array())
  36. {
  37. $records = array();
  38. foreach($this->result as $year => $months)
  39. {
  40. foreach($months as $month => $value)
  41. {
  42. $records[] = array('year' => $year, 'month' => $month, 'value' => $value);
  43. }
  44. }
  45. return $this->filterByOptions($records, $options);
  46. }
  47. }