Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-65230

Recordset interface to get analysables

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: Minor Minor
    • None
    • 3.7
    • Analytics, Performance
    • 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];
      

            Unassigned Unassigned
            dmonllao David Monllaó
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.