• Модуль: imopenlines
  • Путь к файлу: ~/bitrix/modules/imopenlines/lib/integrations/report/statistic.php
  • Класс: BitrixImOpenLinesIntegrationsReportStatistic
  • Вызов: Statistic::execute
public function execute(array &$option)
{
	$lastId = Option::get("imopenlines", 'lastId', 0);
	$executedStepCount = Option::get("imopenlines", 'executedStepCount', 0);

	if ($executedStepCount === 0)
	{
		Option::set("imopenlines", 'statisticPreCalculateFinish', false);
		$this->cleanStatisticTables();
	}

	$sessions = $this->getSessionsFrom($lastId);

	if (!$sessions)
	{
		Option::delete("imopenlines", array('name' => 'lastId'));
		Option::delete("imopenlines", array('name' => 'executedStepCount'));
		Option::set("imopenlines", 'statisticPreCalculateFinish', true);
		return false;
	}

	foreach ($sessions as $session)
	{
		$this->repairIsChatCreatedNew($session);
		$this->writeToStatistics($session);
	}

	$lastExecutedSession = end($sessions);
	$executedStepCount++;
	Option::set("imopenlines", 'lastId', $lastExecutedSession['ID']);
	Option::set("imopenlines", 'executedStepCount', $executedStepCount);
	$option["steps"] = $executedStepCount;
	$option["count"] = (int)(($this->getSessionsCount() / self::SESSION_TO_STATISTIC_PER_ITERATION) + 1);

	return true;

}