You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.0 KiB

  1. <?php
  2. namespace App\Statists;
  3. use App\Task;
  4. use Illuminate\Support\Arr;
  5. use Illuminate\Support\Facades\Cache;
  6. class SprintStatist implements Pipe
  7. {
  8. private Task $task;
  9. public function __construct($task)
  10. {
  11. $this->task = $task;
  12. }
  13. public function handle(&$result, $next)
  14. {
  15. $key = 'sprints.';
  16. $key .= ($this->task->sprint_id ?? 0).'.';
  17. $key .= ($this->task->assignee_id ?? 0).'.';
  18. $key .= $this->task->workflow_id . '.';
  19. $key .= $this->task->status_id;
  20. $map = [
  21. 'total' => 0,
  22. 'test' => 0,
  23. 'overdue' => 0,
  24. 'worked' => 0, // total worked in minute
  25. 'estimate' => 0, // estimate total
  26. ];
  27. $node = Arr::get($result, $key, $map);
  28. $node['total'] = $node['total'] + 1;
  29. $node['test'] = $node['test'] + $result->ready_to_test;
  30. $node['overdue'] = $node['overdue'] + ($result->on_time? 0 : 1);
  31. Arr::set($result, $key, $node);
  32. return $next($result);
  33. }
  34. }