-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f73cbe0
commit cf92839
Showing
8 changed files
with
271 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
namespace tool_excimer; | ||
|
||
/** | ||
* Table for displaying session lock info from profiles grouped by script. | ||
* | ||
* @package tool_excimer | ||
* @author Benjamin Walker <benjaminwalker@catalyst-au.net> | ||
* @copyright 2024, Catalyst IT | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class grouped_session_profile_table extends grouped_script_profile_table { | ||
|
||
/** Columns to be displayed.*/ | ||
const COLUMNS = [ | ||
'maxlockheld', | ||
'minlockheld', | ||
'requestcount', | ||
'maxcreated', | ||
'mincreated', | ||
]; | ||
|
||
/** @var int Only display maximum lockhelds above the threshold. */ | ||
protected $lockheldthreshold; | ||
|
||
/** | ||
* Sets the minimum lockheld threshold. | ||
* | ||
* @param int $duration | ||
*/ | ||
public function set_lockheld_threshold(int $duration) { | ||
$this->lockheldthreshold = $duration; | ||
} | ||
|
||
/** | ||
* Sets the SQL for the table. | ||
*/ | ||
protected function put_sql(): void { | ||
list($filterstring, $filterparams) = $this->get_filter_for_sql(); | ||
|
||
$this->set_count_sql( | ||
"SELECT count(distinct request) | ||
FROM {tool_excimer_profiles} | ||
WHERE $filterstring", | ||
$filterparams | ||
); | ||
|
||
$groupby = $this->get_group_by(); | ||
|
||
$filterstring .= " AND " . $groupby . " IS NOT NULL GROUP BY " . $groupby; | ||
|
||
if ($this->lockheldthreshold) { | ||
$filterstring .= " HAVING MAX(lockheld) > ?"; | ||
$filterparams = array_merge($filterparams, [$this->lockheldthreshold]); | ||
} | ||
|
||
$this->set_sql( | ||
$groupby . ', COUNT(request) as requestcount, MAX(created) as maxcreated, MIN(created) as mincreated, | ||
MAX(lockheld) as maxlockheld, MIN(lockheld) as minlockheld', | ||
'{tool_excimer_profiles}', | ||
$filterstring, | ||
$filterparams | ||
); | ||
} | ||
|
||
/** | ||
* Defines the columns for this table. | ||
* | ||
* @throws \coding_exception | ||
*/ | ||
public function make_columns(): void { | ||
$headers = []; | ||
$columns = $this->get_columns(); | ||
foreach ($columns as $column) { | ||
$headers[] = get_string('field_' . $column, 'tool_excimer'); | ||
} | ||
|
||
$this->define_columns($columns); | ||
$this->column_class('maxlockheld', 'text-right'); | ||
$this->column_class('minlockheld', 'text-right'); | ||
$this->column_class('requestcount', 'text-center'); | ||
$this->define_headers($headers); | ||
} | ||
|
||
/** | ||
* Max lockheld column. | ||
* | ||
* @param \stdClass $record | ||
* @return string | ||
*/ | ||
public function col_maxlockheld(\stdClass $record): string { | ||
return helper::duration_display($record->maxlockheld, !$this->is_downloading()); | ||
} | ||
|
||
/** | ||
* Min lockheld column. | ||
* | ||
* @param \stdClass $record | ||
* @return string | ||
*/ | ||
public function col_minlockheld(\stdClass $record): string { | ||
return helper::duration_display($record->minlockheld, !$this->is_downloading()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
namespace tool_excimer; | ||
|
||
/** | ||
* Display table for profile reports with session lock information. | ||
* | ||
* @package tool_excimer | ||
* @author Benjamin Walker <benjaminwalker@catalyst-au.net> | ||
* @copyright 2024, Catalyst IT | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class session_profile_table extends profile_table { | ||
|
||
/** Columns to be displayed */ | ||
const COLUMNS = [ | ||
'duration', | ||
'lockheld', | ||
'responsecode', | ||
'request', | ||
'reason', | ||
'type', | ||
'created', | ||
'userid', | ||
'courseid', | ||
]; | ||
|
||
/** | ||
* returns the columns defined for the table. | ||
* | ||
* @return string[] | ||
*/ | ||
protected function get_columns(): array { | ||
$columns = self::COLUMNS; | ||
if (!$this->is_downloading()) { | ||
$columns[] = 'actions'; | ||
} | ||
return $columns; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* Long session lock data in a table. | ||
* | ||
* @package tool_excimer | ||
* @author Benjamin Walker <benjaminwalker@catalyst-au.net> | ||
* @copyright 2024, Catalyst IT | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
use tool_excimer\grouped_session_profile_table; | ||
use tool_excimer\profile_table_page; | ||
use tool_excimer\session_profile_table; | ||
|
||
require_once('../../../config.php'); | ||
require_once($CFG->libdir.'/adminlib.php'); | ||
|
||
// The script can either be a URL, or a task name, or whatever may be used | ||
// for a request name. So we need to accept TEXT input. | ||
$script = optional_param('script', '', PARAM_TEXT); | ||
$group = optional_param('group', '', PARAM_TEXT); | ||
|
||
admin_externalpage_setup('tool_excimer_report_session_locks'); | ||
|
||
$url = new moodle_url("/admin/tool/excimer/session_locks.php"); | ||
|
||
if ($script || $group) { | ||
$table = new session_profile_table('profile_table_session_locks'); | ||
$table->sortable(true, 'lockheld', SORT_DESC); | ||
if ($script) { | ||
$table->add_filter('request', $script); | ||
$url->params(['script' => $script]); | ||
} | ||
if ($group) { | ||
$table->add_filter('scriptgroup', $group); | ||
$url->params(['group' => $group]); | ||
$PAGE->navbar->add($group); | ||
} | ||
} else { | ||
$table = new grouped_session_profile_table('profile_table_session_locks'); | ||
$table->set_url_path($url); | ||
$table->set_lockheld_threshold(1); | ||
$table->sortable(true, 'maxlockheld', SORT_DESC); | ||
} | ||
|
||
profile_table_page::display($table, $url); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters