public function get_analysables_iterator(?string $action = null) {
        global $DB, $CFG;

        $siteadmins = explode(',', $CFG->siteadmins);

        list($sql, $params) = $this->get_iterator_sql('user', CONTEXT_USER, $action, 'u');

        $sql .= " AND u.deleted = :deleted AND u.confirmed = :confirmed AND u.suspended = :suspended";
        $params = $params + ['deleted' => 0, 'confirmed' => 1, 'suspended' => 0];

        $ordersql = $this->order_sql('timecreated', 'ASC', 'u');

        $recordset = $DB->get_recordset_sql($sql, $params);
        if (!$recordset->valid()) {
            $this->add_log(get_string('nousersfound'));
            return new \ArrayIterator([]);
        }

        return new \core\dml\recordset_walk($recordset, function($record) use ($siteadmins) {

            if (in_array($record->id, $siteadmins) || isguestuser($record->id)) {
                // Skip admins and the guest user.
                return false;
            }
            $context = \context_helper::preload_from_record($record);
            return \core_analytics\user::instance($record, $context);
        });
    }