-
Improvement
-
Resolution: Done
-
Minor
-
None
-
3.7
-
None
-
MOODLE_37_STABLE
At the moment the get_analysables interface returns an array. The recommended approach is to return the analysable ids in the site so we don't reach PHP's memory limit. This requires each analysable element to separately load their data from db. The current approach is O(n), where n is the number of analysable elements in a site. This is not nice because n can be very large and this query runs every time the analytics scheduled task runs. I propose a new O(1) interface that returns a \moodle_recordset or a \recordset_walk, and that its responsibilities include the job get_sorted_analysables is currently doing. This is done via the left join with analytics_used_analysables.
$select = 'c.*, ' . context_helper::get_preload_record_columns_sql('ctx');
|
$sql = "SELECT $select
|
FROM {course} c
|
JOIN {context} ctx ON (ctx.contextlevel = :contextlevel AND ctx.instanceid = c.id)
|
LEFT JOIN {analytics_used_analysables} aua ON aua.analysableid = c.id
|
WHERE aua.modelid = :modelid AND aua.action = :action
|
ORDER BY aua.timeanalyzed DESC, c.sortorder ASC";
|
$params = ['contextlevel' => CONTEXT_COURSE, 'modelid' => $this->get_modelid(), 'action' => $action];
|
- has a non-specific relationship to
-
MDL-64739 Analytics models may be restricted to category or course contexts
-
- Closed
-