You are here

public function UltimateCronProgress::setProgress in Ultimate Cron 7.2

Set job progress.

Parameters

float $progress: The progress (0 - 1).

File

./ultimate_cron.progress.inc, line 100
Pseudo namespace for progress functions.

Class

UltimateCronProgress
Class for handling Ultimate Cron progress.

Code

public function setProgress($progress) {
  if (microtime(TRUE) >= $this->progressUpdated + $this->interval) {
    $name = 'uc-progress:' . $this->name;
    $target = _ultimate_cron_get_transactional_safe_connection();
    db_merge('variable', array(
      'target' => $target,
    ))
      ->key(array(
      'name' => $name,
    ))
      ->fields(array(
      'value' => serialize($progress),
    ))
      ->execute();
    $this->progressUpdated = microtime(TRUE);
    return TRUE;
  }
  return FALSE;
}