• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/controller/export.php
  • Класс: BitrixMainControllerExport
  • Вызов: Export::preformExpectedDuration
protected function preformExpectedDuration()
{
	$message = '';
	$avgStepDuration = $predictedStepCount = $predictedTimeDuration = 0;
	$avgRowsPerStep = self::ROWS_PER_PAGE;
	if ($this->stepCount > 0 && $this->timeStart > 0)
	{
		$avgStepDuration = round((time() - $this->timeStart) / $this->stepCount);
		if ($this->processedItems > 0)
		{
			$avgRowsPerStep = round($this->processedItems / $this->stepCount);
		}
	}
	if ($this->totalItems > 0)
	{
		$predictedStepCount = round(($this->totalItems - $this->processedItems) / $avgRowsPerStep);
		if ($this->useCloud === true)
		{
			$predictedStepCount *= 2;
		}
	}
	if ($avgStepDuration > 0 && $predictedStepCount > 0)
	{
		$predictedTimeDuration = $avgStepDuration * $predictedStepCount * 1.1;
	}
	if ($predictedTimeDuration > 0)
	{
		$predictedTimeDurationHours = floor($predictedTimeDuration / 3600);
		if ($predictedTimeDurationHours > 0)
		{
			$predictedTimeDurationMinutes = ceil(($predictedTimeDuration - $predictedTimeDurationHours * 3600) / 60);
			$message =
				Loc::getMessage('MAIN_EXPORT_EXPECTED_DURATION').' '.
				Loc::getMessage('MAIN_EXPORT_EXPECTED_DURATION_HOURS', array(
					'#HOURS#' => $predictedTimeDurationHours,
					'#MINUTES#' => $predictedTimeDurationMinutes,
				));
		}
		else
		{
			$predictedTimeDurationMinutes = round($predictedTimeDuration / 60);
			$message =
				Loc::getMessage('MAIN_EXPORT_EXPECTED_DURATION').' '.
				Loc::getMessage('MAIN_EXPORT_EXPECTED_DURATION_MINUTES', array(
					'#MINUTES#' => ($predictedTimeDurationMinutes < 1 ? "< 1" : $predictedTimeDurationMinutes),
				));
		}
	}

	return $message;
}