Skip to content
Snippets Groups Projects
Commit c680b0c2 authored by Andy Hubert's avatar Andy Hubert Committed by Ryan Smith
Browse files

fix: Limits the events processed in the cron to avoid overflows and timeouts...

fix: Limits the events processed in the cron to avoid overflows and timeouts (Thanks @AndyHubert). (#203)
parent 96cafc12
No related branches found
No related tags found
No related merge requests found
......@@ -77,6 +77,10 @@ class store extends php_obj implements log_writer {
}
}
public function get_max_batch_size() {
return $this->get_config('maxbatchsize', 100);
}
public function process_events(array $events) {
global $DB;
global $CFG;
......@@ -108,7 +112,7 @@ class store extends php_obj implements log_writer {
'lrs_endpoint' => $this->get_config('endpoint', ''),
'lrs_username' => $this->get_config('username', ''),
'lrs_password' => $this->get_config('password', ''),
'lrs_max_batch_size' => $this->get_config('maxbatchsize', 100),
'lrs_max_batch_size' => $this->get_max_batch_size(),
],
];
$loadedevents = \src\handler($handlerconfig, $events);
......
......@@ -39,7 +39,12 @@ class emit_task extends \core\task\scheduled_task {
global $DB;
$manager = get_log_manager();
$store = new store($manager);
$extractedevents = $DB->get_records('logstore_xapi_log');
$conditions = null;
$sort = '';
$fields = '*';
$limitfrom = 0;
$limitnum = $store->get_max_batch_size();
$extractedevents = $DB->get_records('logstore_xapi_log', $conditions, $sort, $fields, $limitfrom, $limitnum);
$loadedevents = $store->process_events($extractedevents);
$loadedeventids = array_map(function ($transformedevent) {
return $transformedevent['eventid'];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment