• Модуль: sender
  • Путь к файлу: ~/bitrix/modules/sender/lib/posting/segmentdatabuilder.php
  • Класс: BitrixSenderPostingSegmentDataBuilder
  • Вызов: SegmentDataBuilder::prepareForAgent
public function prepareForAgent($rebuild = false)
{
	if (!$this->connectorIterable())
	{
		return false;
	}

	$groupState = $this->getCurrentGroupState();
	$result = '';

	if (isset($groupState['NEW_CREATED'])
		|| $groupState
		&& ($groupState['ENDPOINT'] !== json_encode($this->endpoint) || $rebuild))
	{
		SegmentDataBuilderJob::removeAgentFromDB($groupState['ID']);
		$this->clearBuilding($groupState['ID']);
		GroupCounterTable::deleteByGroupId($this->groupId);

		$groupState = $this->getCurrentGroupState();

		if ($groupState)
		{
			GroupTable::update($this->groupId, [
				'fields' => ['STATUS' => GroupTable::STATUS_IN_PROGRESS]
			]);

			$result = self::run($groupState['ID'], self::MINIMAL_PER_PAGE);
			SegmentDataBuilderJob::addEventAgent($groupState['ID']);
		}
	}

	return $result !== '';
}