<commit_before><?php
class Vps_Filter_Row_UniqueAscii extends Vps_Filter_Row_Abstract
{
    private $_sourceField;
    private $_groupBy = array();

    public function __construct($sourceField = null)
    {
        $this->_sourceField = $sourceField;
    }

    public function setSourceField($f)
    {
        $this->_sourceField = $f;
    }
    public function getSourceField($f)
    {
        return $this->_sourceField;
    }
    public function setGroupBy($fields)
    {
        if (is_string($fields)) $fields = array($fields);
        $this->_groupBy = $fields;
    }
    public function getGroupBy()
    {
        return $this->_groupBy;
    }

    public function filter($row)
    {
        if (is_null($this->_sourceField)) {
            $value = $row->__toString();
        } else {
            $f = $this->_sourceField;
            $value = $row->$f;
        }
        $value = Vps_Filter::get($value, 'Ascii');

        $where = array();
        foreach ($this->_groupBy as $f) {
            if (is_null($row->$f)) {
                $where["ISNULL($f)"] = '';
            } else {
                $where["$f = ?"] = $row->$f;
            }
        }
        foreach ($row->getPrimaryKey() as $k=>$i) {
            if (is_null($i)) {
                $where["ISNULL($k)"] = '';
            } else {
                $where["$k = ?"] = $i;
            }
        }

        $x = 0;
        $unique = $value;
        $where["$this->_field = ?"] = $unique;
        while ($row->getTable()->fetchAll($where)->count() > 0) {
            $unique = $value . '_' . ++$x;
            $where["$this->_field = ?"] = $unique;
        }
        return $unique;
    }
}<commit_msg>Bug, weil eigene Row ebenfalls abgefragt wurde<commit_after><?php
class Vps_Filter_Row_UniqueAscii extends Vps_Filter_Row_Abstract
{
    private $_sourceField;
    private $_groupBy = array();

    public function __construct($sourceField = null)
    {
        $this->_sourceField = $sourceField;
    }

    public function setSourceField($f)
    {
        $this->_sourceField = $f;
    }
    public function getSourceField($f)
    {
        return $this->_sourceField;
    }
    public function setGroupBy($fields)
    {
        if (is_string($fields)) $fields = array($fields);
        $this->_groupBy = $fields;
    }
    public function getGroupBy()
    {
        return $this->_groupBy;
    }

    public function filter($row)
    {
        if (is_null($this->_sourceField)) {
            $value = $row->__toString();
        } else {
            $f = $this->_sourceField;
            $value = $row->$f;
        }
        $value = Vps_Filter::get($value, 'Ascii');

        $where = array();
        foreach ($this->_groupBy as $f) {
            if (is_null($row->$f)) {
                $where["ISNULL($f)"] = '';
            } else {
                $where["$f = ?"] = $row->$f;
            }
        }
        foreach ($row->getPrimaryKey() as $k=>$i) {
            if (is_null($i)) {
                $where["ISNULL($k)"] = '';
            } else {
                $where["$k = ?"] = $i;
            }
        }

        $x = 0;
        $unique = $value;
        $where["$this->_field = ?"] = $unique;
        $where["$this->_field != ?"] = $row->{$this->_field};
        p($where);
        while ($row->getTable()->fetchAll($where)->count() > 0) {
            $unique = $value . '_' . ++$x;
            $where["$this->_field = ?"] = $unique;
        }
        return $unique;
    }
}
{'fraction_non_alphanumeric': 0.17185697808535177, 'fraction_numerical': 0.0011534025374855825, 'mean_word_length': 1.6975116640746502, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 46, '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': '6620671', 'n_tokens_mistral': 1115, 'n_tokens_neox': 1081, 'n_words': 195}