count_of_annual_created_case.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /**
  3. * 按系统统计的年度新增用例数。
  4. * Count of annual created case.
  5. *
  6. * 范围:system
  7. * 对象:case
  8. * 目的:scale
  9. * 度量名称:按系统统计的年度新增用例数
  10. * 单位:个
  11. * 描述:按系统统计的年度新增用例数是指在一年内新增的测试用例数量。统计年度新增用例数可以帮助评估系统或项目在不同阶段的测试覆盖和测试深度。年度新增用例数的增加可能意味着对新功能和需求进行了更充分的测试。
  12. * 定义:所有用例个数求和;创建时间在某年;过滤已删除的用例;过滤已删除的产品;
  13. *
  14. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
  15. * @author qixinzhi <qixinzhi@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_annual_created_case extends baseCalc
  22. {
  23. public $dataset = 'getAllCases';
  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. if(!isset($this->result[$year])) $this->result[$year] = 0;
  31. $this->result[$year] += 1;
  32. }
  33. public function getResult($options = array())
  34. {
  35. $records = $this->getRecords(array('year', 'value'));
  36. return $this->filterByOptions($records, $options);
  37. }
  38. }