rate_of_finished_story.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * 按系统统计的研发需求完成率。
  4. * Rate of finished story.
  5. *
  6. * 范围:system
  7. * 对象:story
  8. * 目的:rate
  9. * 度量名称:按系统统计的研发需求完成率
  10. * 单位:%
  11. * 描述:按系统统计的研发需求完成率反映了组织按系统统计的已完成研发需求数和按系统统计的有效研发需求数之间的比率,用于评估组织对于进度控制、绩效评估、风险评估、资源规划和利用,以及持续改进和效率提升具有重要意义。
  12. * 定义:复用:;按系统统计的完成研发需求数;按系统统计的有效研发需求数;公式:;按系统统计的研发需求完成率=按系统统计的已完成研发需求数/按系统统计的有效研发需求数*100%;
  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 rate_of_finished_story extends baseCalc
  22. {
  23. public $dataset = 'getAllDevStories';
  24. public $fieldList = array('t1.status', 't1.closedReason');
  25. public $result = array('finished' => 0, 'valid' => 0);
  26. public function calculate($row)
  27. {
  28. if(!isset($this->result['finished'])) $this->result['finished'] = 0;
  29. if(!isset($this->result['valid'])) $this->result['valid'] = 0;
  30. if($row->status == 'closed' and $row->closedReason == 'done') $this->result['finished'] ++;
  31. if(!in_array($row->closedReason, array('duplicate', 'willnotdo', 'bydesign', 'cancel'))) $this->result['valid'] ++;
  32. }
  33. public function getResult($options = array())
  34. {
  35. $this->result = !empty($this->result['valid']) ? round($this->result['finished'] / $this->result['valid'], 4) : 0;
  36. $records = array(array('value' => $this->result));
  37. return $this->filterByOptions($records, $options);
  38. }
  39. }