MDL-82114 files: report entity filters for file component/area.

This commit is contained in:
Paul Holden 2024-06-06 10:40:07 +01:00
parent 5aef789ac6
commit 956c64f0b4
No known key found for this signature in database
GPG Key ID: A81A96D6045F6164
2 changed files with 38 additions and 2 deletions

View File

@ -425,6 +425,26 @@ class file extends base {
))
->add_joins($this->get_joins());
// Component.
$filters[] = (new filter(
text::class,
'component',
new lang_string('plugin'),
$this->get_entity_name(),
"{$filesalias}.component"
))
->add_joins($this->get_joins());
// Area.
$filters[] = (new filter(
text::class,
'area',
new lang_string('pluginarea'),
$this->get_entity_name(),
"{$filesalias}.filearea"
))
->add_joins($this->get_joins());
// Time created.
$filters[] = (new filter(
date::class,

View File

@ -36,7 +36,7 @@ require_once("{$CFG->dirroot}/reportbuilder/tests/helpers.php");
* @copyright 2022 Paul Holden <paulh@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class files_test extends core_reportbuilder_testcase {
final class files_test extends core_reportbuilder_testcase {
/**
* Test default datasource
@ -205,7 +205,7 @@ class files_test extends core_reportbuilder_testcase {
*
* @return array[]
*/
public function datasource_filters_provider(): array {
public static function datasource_filters_provider(): array {
return [
// File.
'Filter directory' => ['file:directory', [
@ -247,6 +247,22 @@ class files_test extends core_reportbuilder_testcase {
'file:contenthash_operator' => text::IS_EQUAL_TO,
'file:contenthash_value' => 'f00f',
], 0],
'Filter component' => ['file:component', [
'file:component_operator' => text::IS_EQUAL_TO,
'file:component_value' => 'course',
], 2],
'Filter component (no match)' => ['file:component', [
'file:component_operator' => text::IS_EQUAL_TO,
'file:component_value' => 'reportbuilder',
], 0],
'Filter area' => ['file:area', [
'file:area_operator' => text::IS_EQUAL_TO,
'file:area_value' => 'summary',
], 2],
'Filter area (no match)' => ['file:area', [
'file:area_operator' => text::IS_EQUAL_TO,
'file:area_value' => 'report',
], 0],
'Filter time created' => ['file:timecreated', [
'file:timecreated_operator' => date::DATE_RANGE,
'file:timecreated_from' => 1622502000,