Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions lib/Cake/Console/Helper/ProgressShellHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function increment($num = 1) {
*
* @return void
*/
public function draw() {
public function draw($logged_percentage = 0) {
$numberLen = strlen(' 100%');
$complete = round($this->_progress / $this->_total, 2);
$barLen = ($this->_width - $numberLen) * ($this->_progress / $this->_total);
Expand All @@ -115,8 +115,11 @@ public function draw() {
if ($pad > 0) {
$bar .= str_repeat(' ', $pad);
}
$percent = ($complete * 100) . '%';
$bar .= str_pad($percent, $numberLen, ' ', STR_PAD_LEFT);
$this->_consoleOutput->overwrite($bar, 0);
$percent = ($complete * 100);
$bar .= str_pad($percent . '%', $numberLen, ' ', STR_PAD_LEFT);
if ($percent % 10 === 0 && $percent !== $logged_percentage) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this check for @JINGJINGTANG ?
$percent !== $logged_percentage

Copy link
Collaborator Author

@JINGJINGTANG JINGJINGTANG Oct 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to make sure we are only logging the same progress (percentage) once to the log file. Since we are logging the progress to a log file, we can't have it overwritten the previous log. Thus, we are logging 0%, 10%, 20%...etc

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the mcap parse, we would have this inside the for loop: $logged_percentage = $progress->draw($logged_percentage);

CakeLog::write('debug', $bar);
}
return $percent;
}
}