protected function update_analysable_analysed_time(array $processedanalysables, int $analysableid) {
        global $DB;

        $now = time();

        if (!empty($processedanalysables[$analysableid])) {
            $obj = $processedanalysables[$analysableid];

            $obj->id = $obj->primarykey;
            unset($obj->primarykey);

            $obj->timeanalysed = $now;

            $DB->update_record('analytics_used_analysables', $obj);

        } else {

            $obj = new \stdClass();
            $obj->modelid = $this->analyser->get_modelid();
            $obj->action = ($this->includetarget) ? 'training' : 'prediction';
            $obj->analysableid = $analysableid;
            $obj->firstanalysis = $now;
            $obj->timeanalysed = $now;

            $obj->primarykey = $DB->insert_record('analytics_used_analysables', $obj);

            // Update the cache just in case it is used in the same request.
            $key = $this->analyser->get_modelid() . '_' . $analysableid;
            $cache = \cache::make('core', 'modelfirstanalyses');
            $cache->set($key, $now);
        }
    }