Skip to content

Commit

Permalink
Merge pull request #11 from ITspirit/fix-workload-typo
Browse files Browse the repository at this point in the history
Fix Typo of "setWorloadCompleted"
  • Loading branch information
fashxp committed Dec 28, 2018
2 parents 820f28c + 9cf4e87 commit e0d5d56
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 12 deletions.
2 changes: 1 addition & 1 deletion doc/01_ProcessManager.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class SampleCommand extends AbstractCommand {
$monitoringItem->getLogger()->debug('Testmessage');

//do your work and updates here...
$monitoringItem->setCurrentStep(1)->setWorloadCompleted()->setMessage('Done -> moving on')->save();
$monitoringItem->setCurrentStep(1)->setWorkloadCompleted()->setMessage('Done -> moving on')->save();

$monitoringItem->setCurrentStep(2)->setMessage('Cleaning up something')->save();
$monitoringItem->setMessage('Finished')->setCompleted();
Expand Down
19 changes: 15 additions & 4 deletions src/Elements/Bundle/ProcessManagerBundle/Model/MonitoringItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -523,9 +523,18 @@ public function resetWorkload()
}

/**
* @deprecated Use setWorkloadCompleted() instead
* @return $this
*/
public function setWorloadCompleted()
{
return $this->setWorkloadCompleted();
}

/**
* @return $this
*/
public function setWorkloadCompleted()
{
$this->setCurrentWorkload($this->getTotalWorkload());

Expand All @@ -538,14 +547,16 @@ public function getDuration()
if ($took > 0) {
if ($took < 60) {
return $took.'s';
} elseif ($took < 3600) {
}

if ($took < 3600) {
$minutes = floor($took / 60);
$seconds = $took - ($minutes * 60);

return $minutes.'m '.$seconds.'s';
} else {
return gmdate('h', $took).'h '.gmdate('i', $took).'m '.gmdate('s', $took).'s';
}

return gmdate('h', $took).'h '.gmdate('i', $took).'m '.gmdate('s', $took).'s';
}
}

Expand Down Expand Up @@ -623,7 +634,7 @@ public function resetState()

public function setCompleted()
{
$this->setWorloadCompleted();
$this->setWorkloadCompleted();
$this->setCurrentStep($this->getTotalSteps());
//do not change the state if set it to failed - otherwise it would appear to be successfully finished
if ($this->getStatus() != self::STATUS_FAILED) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function run()
$logger->error($e);
}
$job->unlock();
$monitoringItem->setWorloadCompleted()->save();
$monitoringItem->setWorkloadCompleted()->save();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
$total = $list->getTotalCount();
$perLoop = 50;

for ($i = 0; $i < (ceil($total / $perLoop)); $i++) {
for ($k = 0, $kMax = ceil($total / $perLoop); $k < $kMax; $k++) {
$list->setLimit($perLoop);
$offset = $i * $perLoop;
$offset = $k * $perLoop;
$list->setOffset($offset);

$monitoringItem->setCurrentWorkload(($offset ?: 1))
Expand All @@ -87,7 +87,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
}

$monitoringItem->setWorloadCompleted()->save();
$monitoringItem->setWorkloadCompleted()->save();
\Pimcore::collectGarbage();
}
$monitoringItem->setCurrentStep($totalSteps)->setCurrentWorkload(0)->setTotalWorkload(0)->setMessage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ public function execute()
$total = $list->getTotalCount();
$perLoop = 50;

for ($i = 0; $i < (ceil($total / $perLoop)); $i++) {
for ($k = 0; $k < (ceil($total / $perLoop)); $k++) {
$list->setLimit($perLoop);
$offset = $i * $perLoop;
$offset = $k * $perLoop;
$list->setOffset($offset);

$monitoringItem->setCurrentWorkload(($offset ?: 1))
Expand All @@ -66,7 +66,7 @@ public function execute()
}
}

$monitoringItem->setWorloadCompleted()->save();
$monitoringItem->setWorkloadCompleted()->save();
\Pimcore::collectGarbage();
}

Expand Down

0 comments on commit e0d5d56

Please sign in to comment.