- Модуль: disk
- Путь к файлу: ~/bitrix/modules/disk/lib/volume/base.php
- Класс: BitrixDiskVolumeBase
- Вызов: Base::recalculatePercent
public function recalculatePercent($totalSizeIndicator = null, $excludeSizeIndicator = null): self
{
if ($totalSizeIndicator instanceof VolumeIVolumeIndicator)
{
$totalSizeIndicator->loadTotals();
$total = $totalSizeIndicator->getTotalSize() + $totalSizeIndicator->getPreviewSize();
}
else
{
$this->loadTotals();
$total = $this->getTotalSize() + $this->getPreviewSize();
}
if ($total > 0)
{
$connection = Application::getConnection();
$tableName = VolumeTable::getTableName();
$filter = $this->getFilter(
[
'=INDICATOR_TYPE' => static::className(),
'=OWNER_ID' => $this->getOwner(),
'>FILE_COUNT' => 0,
'>FILES_LEFT' => 0,
],
VolumeTable::getEntity()
);
$where = Query::buildFilterSql(VolumeTable::getEntity(), $filter);
$sql = 'UPDATE '.$tableName.' SET PERCENT = ROUND((FILE_SIZE + PREVIEW_SIZE) * 100 / '.$total.', 4) WHERE '.$where;
$connection->queryExecute($sql);
}
return $this;
}