• Модуль: sender
  • Путь к файлу: ~/bitrix/modules/sender/lib/internals/countercalculation.php
  • Класс: Bitrix\Sender\Internals\CounterCalculation
  • Вызов: CounterCalculation::updatePostingReadCounters
static function updatePostingReadCounters($type)
{
	$dataDb = \Bitrix\Sender\PostingRecipientTable::getList(array(
		'select' => array(
			'POSTING_ID',
			'CNT'
		),
		'filter' => array(
			'=UPDATE_POSTING.COUNT_' . $type => 0,
			'>CNT' => 0,
			'=IS_' . $type => 'Y'
		),
		'runtime' => array(
			new \Bitrix\Main\Entity\ReferenceField(
				'UPDATE_POSTING',
				'Bitrix\Sender\PostingTable',
				array('=this.POSTING_ID' => 'ref.ID'),
				array('join_type' => 'INNER')
			),
			new \Bitrix\Main\Entity\ExpressionField('CNT', 'COUNT(%s)', 'ID')
		),
		'order' => array('CNT' => 'DESC', 'POSTING_ID' => 'ASC'),
	));

	while($item = $dataDb->fetch())
	{
		if(self::isTimeUp())
		{
			return true;
		}

		Model\PostingTable::update($item['POSTING_ID'], array('COUNT_' . $type => $item['CNT']));
	}

	return false;
}