- Модуль: disk
- Путь к файлу: ~/bitrix/modules/disk/lib/volume/module/module.php
- Класс: BitrixDiskVolumeModuleindicator
- Вызов: indicator::recalculatePercent
public function recalculatePercent($totalSizeIndicator = '\Bitrix\Disk\Volume\Bfile', $excludeSizeIndicator = null): self
{
if (is_string($totalSizeIndicator) && !empty($totalSizeIndicator) && class_exists($totalSizeIndicator))
{
/** @var VolumeBfile $totalSizeIndicator */
$totalSizeIndicator = new $totalSizeIndicator();
}
if (!($totalSizeIndicator instanceof VolumeIVolumeIndicator))
{
throw new MainArgumentException('Wrong parameter totalSizeIndicator');
}
$totalSizeIndicator->setOwner($this->getOwner());
$totalSizeIndicator->loadTotals();
if ($totalSizeIndicator->getTotalSize() > 0)
{
$connection = Application::getConnection();
$tableName = VolumeTable::getTableName();
$filter = $this->getFilter(
[
'=INDICATOR_TYPE' => static::className(),
'=OWNER_ID' => $this->getOwner(),
'>FILE_COUNT' => 0,
],
VolumeTable::getEntity()
);
$where = Query::buildFilterSql(VolumeTable::getEntity(), $filter);
$total = $totalSizeIndicator->getTotalSize() + $totalSizeIndicator->getPreviewSize();
$sql = 'UPDATE '.$tableName.' SET PERCENT = ROUND((FILE_SIZE + PREVIEW_SIZE) * 100 / '.$total.', 4) WHERE '.$where;
$connection->queryExecute($sql);
}
return $this;
}