• Модуль: disk
  • Путь к файлу: ~/bitrix/modules/disk/lib/volume/module/subscribe.php
  • Класс: BitrixDiskVolumeModuleSubscribe
  • Вызов: Subscribe::measure
public function measure(array $collectData = []): self
{
	if (!$this->isMeasureAvailable())
	{
		$this->addError(new BitrixMainError('', self::ERROR_MEASURE_UNAVAILABLE));
		return $this;
	}

	$connection = BitrixMainApplication::getConnection();
	$indicatorType = $connection->getSqlHelper()->forSql(static::className());
	$ownerId = (string)$this->getOwner();

	$querySql = "
		SELECT 
			'{$indicatorType}' as INDICATOR_TYPE,
			{$ownerId} as OWNER_ID,
			". $connection->getSqlHelper()->getCurrentDateTimeFunction(). " as CREATE_TIME,
			SUM(files.FILE_SIZE) as FILE_SIZE,
			COUNT(files.ID) as FILE_COUNT,
			0 as DISK_SIZE,
			0 as DISK_COUNT
		FROM
			b_file files
			INNER JOIN b_posting_file attachment
				ON files.id = attachment.FILE_ID
	";

	$columnList = VolumeQueryHelper::prepareInsert(
		[
			'INDICATOR_TYPE',
			'OWNER_ID',
			'CREATE_TIME',
			'FILE_SIZE',
			'FILE_COUNT',
			'DISK_SIZE',
			'DISK_COUNT',
		],
		$this->getSelect()
	);

	$tableName = VolumeTable::getTableName();

	$connection->queryExecute("INSERT INTO {$tableName} ({$columnList}) {$querySql}");

	return $this;
}