Skip to content

Commit 725a3f9

Browse files
committed
MDL-70854 core: Alters running tasks page to show progress bars
1 parent 6fb28f1 commit 725a3f9

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

admin/tool/task/classes/running_tasks_table.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public function __construct() {
4949
'classname' => get_string('classname', 'tool_task'),
5050
'type' => get_string('tasktype', 'admin'),
5151
'time' => get_string('taskage', 'tool_task'),
52+
'progress' => get_string('progress', 'core'),
5253
'timestarted' => get_string('started', 'tool_task'),
5354
'hostname' => get_string('hostname', 'tool_task'),
5455
'pid' => get_string('pid', 'tool_task'),
@@ -153,4 +154,29 @@ public function col_time($row): string {
153154
public function col_timestarted($row): string {
154155
return userdate($row->timestarted);
155156
}
157+
158+
/**
159+
* Format the progress column.
160+
*
161+
* @param \stdClass $row
162+
* @return string
163+
*/
164+
public function col_progress($row): string {
165+
global $DB;
166+
167+
// Check to see if there is a stored progress record for this task.
168+
if ($row->type === 'adhoc') {
169+
$idnumber = \core\stored_progress_bar::convert_to_idnumber($row->classname, $row->id);
170+
} else {
171+
$idnumber = \core\stored_progress_bar::convert_to_idnumber($row->classname);
172+
}
173+
174+
$bar = \core\stored_progress_bar::get_by_idnumber($idnumber);
175+
if ($bar) {
176+
return $bar->get_content();
177+
} else {
178+
return '-';
179+
}
180+
}
181+
156182
}

admin/tool/task/runningtasks.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
* @copyright 2020 Mikhail Golenkov <[email protected]>
2323
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
2424
*/
25+
define('NO_OUTPUT_BUFFERING', true);
2526

2627
require_once(__DIR__ . '/../../../config.php');
2728
require_once($CFG->libdir.'/adminlib.php');

0 commit comments

Comments
 (0)