MDL-74497 reportbuilder: Use new methods in existing datasources

- 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().
This commit is contained in:
David Matamoros
2022-05-13 08:36:31 +02:00
parent 9a8091d550
commit 5e68da7868
3 changed files with 6 additions and 29 deletions
@@ -70,20 +70,8 @@ class cohorts extends datasource {
$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();
}
/**
@@ -63,17 +63,8 @@ class courses extends datasource {
->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();
}
/**
@@ -56,13 +56,11 @@ class users extends datasource {
$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);
}
/**