count_of_user_in_project.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * 按项目统计的人员总数。
  4. * Count of user in project.
  5. *
  6. * 范围:project
  7. * 对象:user
  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_user_in_project extends baseCalc
  22. {
  23. public $dataset = 'getTeamMembers';
  24. public $fieldList = array('t3.id as project', 't1.account');
  25. public $result = array();
  26. public function calculate($row)
  27. {
  28. $project = $row->project;
  29. $account = $row->account;
  30. if(!isset($this->result[$project])) $this->result[$project] = array();
  31. $this->result[$project][$account] = $account;
  32. }
  33. public function getResult($options = array())
  34. {
  35. foreach($this->result as $project => $users)
  36. {
  37. if(!is_array($users)) continue;
  38. $this->result[$project] = count($users);
  39. }
  40. $records = $this->getRecords(array('project', 'value'));
  41. return $this->filterByOptions($records, $options);
  42. }
  43. }