Skip to content

Commit

Permalink
fix: Limits the events processed in the cron to avoid overflows and t…
Browse files Browse the repository at this point in the history
…imeouts (Thanks @AndyHubert). (#203)
  • Loading branch information
AndyHubert authored and ryasmi committed Aug 1, 2018
1 parent 96cafc1 commit c680b0c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion classes/log/store.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ protected function insert_event_entries(array $events) {
}
}

public function get_max_batch_size() {
return $this->get_config('maxbatchsize', 100);
}

public function process_events(array $events) {
global $DB;
global $CFG;
Expand Down Expand Up @@ -108,7 +112,7 @@ public function process_events(array $events) {
'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);
Expand Down
7 changes: 6 additions & 1 deletion classes/task/emit_task.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ public function execute() {
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'];
Expand Down

0 comments on commit c680b0c

Please sign in to comment.