• Модуль: sender
  • Путь к файлу: ~/bitrix/modules/sender/lib/stat/statistics.php
  • Класс: BitrixSenderStatStatistics
  • Вызов: Statistics::getCountersDynamic
public function getCountersDynamic()
{
	$list = array();
	$filter = $this->getMappedFilter();
	$select = array(
		'SEND_ALL' => 'COUNT_SEND_ALL',
		'SEND_ERROR' => 'COUNT_SEND_ERROR',
		'SEND_SUCCESS' => 'COUNT_SEND_SUCCESS',
		'READ' => 'COUNT_READ',
		'CLICK' => 'COUNT_CLICK',
		'UNSUB' => 'COUNT_UNSUB'
	);
	$runtime = array(
		new ExpressionField('CNT', 'COUNT(%s)', 'ID'),
		new ExpressionField('DATE', 'DATE(%s)', 'DATE_SENT'),
	);
	foreach ($select as $alias => $fieldName)
	{
		$runtime[] = new ExpressionField($alias, 'SUM(%s)', $fieldName);
	}
	$select = array_keys($select);
	$select[] = 'DATE';
	$select[] = 'CNT';
	$listDb = PostingTable::getList(array(
		'select' => $select,
		'filter' => $filter,
		'runtime' => $runtime,
		'order' => array('DATE' => 'ASC'),
		'cache' => array('ttl' => $this->getCacheTtl(), 'cache_joins' => true)
	));
	while($item = $listDb->fetch())
	{
		$date = null;
		foreach ($item as $name => $value)
		{
			if (!in_array($name, array('DATE')))
			{
				continue;
			}

			if ($item['DATE'])
			{
				/** @var Date $date */
				$date = $item['DATE']->getTimestamp();
			}
		}

		$counters = array();
		foreach ($item as $name => $value)
		{
			if (!in_array($name, array('READ', 'CLICK', 'UNSUB')))
			{
				continue;
			}
			else
			{
				$base = $item['SEND_SUCCESS'];
			}

			$counter = self::getCounterCalculation($name, $value, $base);
			$counter['DATE'] = $date;
			$counters[] = $counter;
			$list[$name][] = $counter;
		}

		$effCounter = self::calculateEfficiency($counters, 1);
		$effCounter['DATE'] = $date;
		$list['EFFICIENCY'][] = $effCounter;
	}

	return $list;

}