- Модуль: tasks
- Путь к файлу: ~/bitrix/modules/tasks/lib/scrum/service/entityservice.php
- Класс: BitrixTasksScrumServiceEntityService
- Вызов: EntityService::getCounters
public function getCounters(
int $groupId,
int $entityId,
TaskService $taskService,
$skipCompletedTasks = true
): array
{
$taskIds = [];
$storyPoints = '';
$countTotal = 0;
$storyPointsMap = [];
try
{
$queryObject = EntityTable::getList([
'select' => [
'SOURCE_ID' => 'ITEMS.SOURCE_ID',
'STORY_POINTS' => 'ITEMS.STORY_POINTS',
],
'filter' => [
'ID' => $entityId,
'GROUP_ID' => $groupId,
'=ITEMS.ACTIVE' => 'Y',
],
]);
while ($data = $queryObject->fetch())
{
$storyPointsMap[$data['SOURCE_ID']] = $data['STORY_POINTS'];
}
$tasksInfo = [];
if ($storyPointsMap)
{
$tasksInfo = $taskService->getTasksInfo(array_keys($storyPointsMap));
}
$parentIdsToCheck = [];
foreach ($tasksInfo as $taskId => $taskInfo)
{
$parentId = (int) $taskInfo['PARENT_ID'];
if ($parentId)
{
$parentIdsToCheck[$taskId] = $parentId;
}
else
{
$taskIds[] = $taskId;
}
}
$actualParentIds = [];
if ($parentIdsToCheck)
{
$actualParentIds = $taskService->getActualParentIds($parentIdsToCheck, $groupId);
}
foreach ($actualParentIds as $taskId => $parentId)
{
if (!$parentId)
{
$taskIds[] = $taskId;
}
}
if ($skipCompletedTasks)
{
$taskIds = $taskService->getUncompletedTaskIds($taskIds);
}
foreach ($taskIds as $taskId)
{
$countTotal++;
if (is_numeric($storyPointsMap[$taskId]))
{
$storyPoints = (float) $storyPoints + (float) $storyPointsMap[$taskId];
}
}
}
catch (Exception $exception)
{
$this->errorCollection->setError(
new Error(
$exception->getMessage(),
self::ERROR_COULD_NOT_GET_STORY_POINTS
)
);
}
return [
'taskIds' => $taskIds,
'storyPoints' => $storyPoints,
'countTotal' => $countTotal,
];
}