<commit_before><?php
/**
 * The indexes helper function
 *
 */

namespace Minds\Core\Data;

use Minds\Core;

class indexes
{
    private $db;
    private $namespace = '';

    public function __construct($namespace = null)
    {
        $this->db = new Call('entities_by_time');

        if ($namespace) {
            $this->setNamespace($namespace);
        }
    }

    public function setNamespace($namespace)
    {
        $this->namespace = $namespace . ':';
    }

    public function set($name, array $guids = array())
    {
        return $this->insert($this->namespace.$name, $guids);
    }

        /**
     * Get from the index (returns uuids)
     *
     * @param string/int $key_id - the ID for the row to return
     * @param array $options - limit, offset, reversed
     */
    public function get($key_id, array $options = array('limit'=>12, 'offset'=>'','reversed'=>true))
    {
        try {
            return $this->db->getRow($this->namespace.$key_id, $options);
        } catch (\Exception $e) {
            return false;
        }
    }

    public function remove($key, array $guids = array())
    {
        $this->db->removeAttributes($this->namespace.$key, $guids);
    }

    /**
     * Static methods
     */
     public static function fetch($key, array $options = array('limit'=>12, 'offset'=>'','reversed'=>true))
     {
         $db = new Call('entities_by_time');
         try {
             return $db->getRow($key, $options);
         } catch (\Exception $e) {
             return false;
         }
     }
}<commit_msg>(fix): fix index insert not working<commit_after><?php
/**
 * The indexes helper function
 *
 */

namespace Minds\Core\Data;

use Minds\Core;

class indexes
{
    private $db;
    private $namespace = '';

    public function __construct($namespace = null)
    {
        $this->db = new Call('entities_by_time');

        if ($namespace) {
            $this->setNamespace($namespace);
        }
    }

    public function setNamespace($namespace)
    {
        $this->namespace = $namespace . ':';
    }

    public function set($name, array $guids = array())
    {
        return $this->insert($this->namespace.$name, $guids);
    }

        /**
     * Get from the index (returns uuids)
     *
     * @param string/int $key_id - the ID for the row to return
     * @param array $options - limit, offset, reversed
     */
    public function get($key_id, array $options = array('limit'=>12, 'offset'=>'','reversed'=>true))
    {
        try {
            return $this->db->getRow($this->namespace.$key_id, $options);
        } catch (\Exception $e) {
            return false;
        }
    }

    public function remove($key, array $guids = array())
    {
        $this->db->removeAttributes($this->namespace.$key, $guids);
    }

    /**
     * Pass other functions back to Call (its a hack)
     * @param $name
     * @param $args
     * @return mixed
     */
    public function __call($name, $args) { 
        return $this->db->$name(...$args);
    }

    /**
     * Static methods
     */
     public static function fetch($key, array $options = array('limit'=>12, 'offset'=>'','reversed'=>true))
     {
         $db = new Call('entities_by_time');
         try {
             return $db->getRow($key, $options);
         } catch (\Exception $e) {
             return false;
         }
     }
}
{'fraction_non_alphanumeric': 0.15648286140089418, 'fraction_numerical': 0.002384500745156483, 'mean_word_length': 2.081726354453627, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2841997', 'n_tokens_mistral': 1012, 'n_tokens_neox': 986, 'n_words': 240}