Skip to content

Commit

Permalink
MDL-74497 reportbuilder: Use new methods in existing datasources
Browse files Browse the repository at this point in the history
- Replace all individual calls to add all columns, filters and
conditions on the cohorts datasource with the new
method add_all_from_entities().

- Replace all individual calls to add all columns, filters and
conditions on the courses datasource with the new
method add_all_from_entities().

- Replace all individual calls to add all columns, filters and
conditions on the users datasource with the new
method add_all_from_entity().
  • Loading branch information
dravek committed May 13, 2022
1 parent 9a8091d commit 5e68da7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 29 deletions.
16 changes: 2 additions & 14 deletions cohort/classes/reportbuilder/datasource/cohorts.php
Expand Up @@ -70,20 +70,8 @@ protected function initialise(): void {

$this->add_entity($userentity->add_joins([$cohortmemberjoin, $userjoin]));

// Add all columns from entities to be available in custom reports.
$this->add_columns_from_entity($cohortentity->get_entity_name());
$this->add_columns_from_entity($cohortmemberentity->get_entity_name());
$this->add_columns_from_entity($userentity->get_entity_name());

// Add all filters from entities to be available in custom reports.
$this->add_filters_from_entity($cohortentity->get_entity_name());
$this->add_filters_from_entity($cohortmemberentity->get_entity_name());
$this->add_filters_from_entity($userentity->get_entity_name());

// Add all conditions from entities to be available in custom reports.
$this->add_conditions_from_entity($cohortentity->get_entity_name());
$this->add_conditions_from_entity($cohortmemberentity->get_entity_name());
$this->add_conditions_from_entity($userentity->get_entity_name());
// Add all columns/filters/conditions from entities to be available in custom reports.
$this->add_all_from_entities();
}

/**
Expand Down
13 changes: 2 additions & 11 deletions course/classes/reportbuilder/datasource/courses.php
Expand Up @@ -63,17 +63,8 @@ protected function initialise(): void {
->add_join("JOIN {course_categories} {$coursecattablealias}
ON {$coursecattablealias}.id = {$coursetablealias}.category"));

// Add all columns from entities to be available in custom reports.
$this->add_columns_from_entity($coursecatentity->get_entity_name());
$this->add_columns_from_entity($courseentity->get_entity_name());

// Add all filters from entities to be available in custom reports.
$this->add_filters_from_entity($coursecatentity->get_entity_name());
$this->add_filters_from_entity($courseentity->get_entity_name());

// Add all conditions from entities to be available in custom reports.
$this->add_conditions_from_entity($coursecatentity->get_entity_name());
$this->add_conditions_from_entity($courseentity->get_entity_name());
// Add all columns/filters/conditions from entities to be available in custom reports.
$this->add_all_from_entities();
}

/**
Expand Down
6 changes: 2 additions & 4 deletions user/classes/reportbuilder/datasource/users.php
Expand Up @@ -56,13 +56,11 @@ protected function initialise(): void {
$userparamguest => $CFG->siteguest,
]);

// Add all columns from entities to be available in custom reports.
$this->add_entity($userentity);

// Add all columns/filters/conditions from entities to be available in custom reports.
$userentityname = $userentity->get_entity_name();
$this->add_columns_from_entity($userentityname);
$this->add_filters_from_entity($userentityname);
$this->add_conditions_from_entity($userentityname);
$this->add_all_from_entity($userentityname);
}

/**
Expand Down

0 comments on commit 5e68da7

Please sign in to comment.