Skip to content

Commit

Permalink
MDL-82114 files: report entity filters for file component/area.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulholden committed Jun 28, 2024
1 parent 5aef789 commit 956c64f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
20 changes: 20 additions & 0 deletions files/classes/reportbuilder/local/entities/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,26 @@ protected function get_all_filters(): array {
))
->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,
Expand Down
20 changes: 18 additions & 2 deletions files/tests/reportbuilder/datasource/files_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* @copyright 2022 Paul Holden <[email protected]>
* @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
Expand Down Expand Up @@ -205,7 +205,7 @@ public function test_datasource_non_default_columns(): void {
*
* @return array[]
*/
public function datasource_filters_provider(): array {
public static function datasource_filters_provider(): array {
return [
// File.
'Filter directory' => ['file:directory', [
Expand Down Expand Up @@ -247,6 +247,22 @@ public function datasource_filters_provider(): array {
'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,
Expand Down

0 comments on commit 956c64f

Please sign in to comment.