- Модуль: tasks
- Путь к файлу: ~/bitrix/modules/tasks/lib/internals/counter/counterprocessor.php
- Класс: BitrixTasksInternalsCounterCounterProcessor
- Вызов: CounterProcessor::recount
public function recount(string $counter, array $taskIds = []): void
{
if (!array_key_exists($counter, CounterDictionary::MAP_COUNTERS))
{
throw new UnknownCounterException();
}
$targetTasks = $taskIds;
if (empty($targetTasks))
{
$targetTasks = $this->getUserTasks();
}
if (count($targetTasks) > self::STEP_LIMIT)
{
$chunks = array_chunk($targetTasks, self::STEP_LIMIT);
/**
* the first one will be return for immediately counting
*/
$targetTasks = array_shift($chunks);
foreach ($chunks as $i => $rows)
{
$this->addToQueue($counter, $rows);
}
(new CounterQueueAgent())->addAgent();
}
$counters = $this->getCollector()->recount($counter, $targetTasks);
$counterTypes = CounterDictionary::MAP_COUNTERS[$counter];
if ($counter === CounterDictionary::COUNTER_EXPIRED)
{
$counterTypes = array_merge(array_values(CounterDictionary::MAP_EXPIRED), CounterDictionary::MAP_MUTED_EXPIRED);
}
else if ($counter === CounterDictionary::COUNTER_NEW_COMMENTS)
{
$counterTypes = array_merge(array_values(CounterDictionary::MAP_COMMENTS), CounterDictionary::MAP_MUTED_COMMENTS);
}
$this->reset($counterTypes, $taskIds);
$this->batchInsert($counters);
CounterState::getInstance($this->userId)->updateState($counters, $counterTypes, $taskIds);
}