<commit_before><?php

class AcheteurClient extends sfCouchdbClient {

    protected $_acheteurs = null;

    public function getAll($hydrate = sfCouchdbClient::HYDRATE_DOCUMENT) {
        return $this->startkey('ACHAT-0000000000')->endkey('ACHAT-9999999999')->execute($hydrate);
    }

    public function loadAcheteurs() {
        $cooperatives = $this->startkey(array('Cooperative'))
                ->endkey(array('Cooperative', array()))
                ->executeView('ACHAT', 'qualite');
        $negociants = $this->startkey(array('Negociant'))
                ->endkey(array('Negociant', array()))
                ->executeView('ACHAT', 'qualite');
        $negocaves = $this->startkey(array('NegoCave'))
                ->endkey(array('NegoCave', array()))
                ->executeView('ACHAT', 'qualite');

        $acheteurs_negociant = array();
        $acheteurs_cave = array();
        $acheteurs_mout = array();
        foreach ($cooperatives as $key => $value) {
            $acheteurs_cave[$value->cvi]['cvi'] = $value->cvi;
            $acheteurs_cave[$value->cvi]['commune'] = $value->commune;
            $acheteurs_cave[$value->cvi]['nom'] = $value->nom;

            $acheteurs_mout[$value->cvi]['cvi'] = $value->cvi;
            $acheteurs_mout[$value->cvi]['commune'] = $value->commune;
            $acheteurs_mout[$value->cvi]['nom'] = $value->nom;
        }
        foreach ($negociants as $key => $value) {
            $acheteurs_negociant[$value->cvi]['cvi'] = $value->cvi;
            $acheteurs_negociant[$value->cvi]['commune'] = $value->commune;
            $acheteurs_negociant[$value->cvi]['nom'] = $value->nom;

            $acheteurs_mout[$value->cvi]['cvi'] = $value->cvi;
            $acheteurs_mout[$value->cvi]['commune'] = $value->commune;
            $acheteurs_mout[$value->cvi]['nom'] = $value->nom;
        }

        foreach ($negocaves as $key => $value) {
            $acheteurs_negociant[$value->cvi]['cvi'] = $value->cvi;
            $acheteurs_negociant[$value->cvi]['commune'] = $value->commune;
            $acheteurs_negociant[$value->cvi]['nom'] = $value->nom;

            $acheteurs_mout[$value->cvi]['cvi'] = $value->cvi;
            $acheteurs_mout[$value->cvi]['commune'] = $value->commune;
            $acheteurs_mout[$value->cvi]['nom'] = $value->nom;
        }

        uasort($acheteurs_mout, 'AcheteurClient::sortByNom');

        $acheteurs = array();
        $acheteurs['negoces'] = $acheteurs_negociant;
        $acheteurs['cooperatives'] = $acheteurs_cave;
        $acheteurs['mouts'] = $acheteurs_mout;
        return $acheteurs;
    }

    public function retrieveByCvi($cvi, $hydrate = sfCouchdbClient::HYDRATE_DOCUMENT) {
        return parent::retrieveDocumentById('ACHAT-' . $cvi, $hydrate);
    }

    public static function sortByNom($a, $b) {
        return strcmp($a['nom'], $b['nom']);
    }

    protected function loadAcheteursList($type) {
        if (is_null($this->_acheteurs)) {
            $this->_acheteurs = CacheFunction::cache('model', array($this, 'loadAcheteurs'), array(), 31556926);
        }

        return $this->_acheteurs[$type];
    }

    public function getNegoces() {
        return $this->loadAcheteursList('negoces');
    }

    public function getCooperatives() {
        return $this->loadAcheteursList('cooperatives');
    }

    public function getMouts() {
        return $this->loadAcheteursList('mouts');
    }

}
<commit_msg>Bug le négocave apparaissait en bas de la liste<commit_after><?php

class AcheteurClient extends sfCouchdbClient {

    protected $_acheteurs = null;

    public function getAll($hydrate = sfCouchdbClient::HYDRATE_DOCUMENT) {
        return $this->startkey('ACHAT-0000000000')->endkey('ACHAT-9999999999')->execute($hydrate);
    }

    public function loadAcheteurs() {
        $cooperatives = $this->startkey(array('Cooperative'))
                ->endkey(array('Cooperative', array()))
                ->executeView('ACHAT', 'qualite');
        $negociants = $this->startkey(array('Negociant'))
                ->endkey(array('Negociant', array()))
                ->executeView('ACHAT', 'qualite');
        $negocaves = $this->startkey(array('NegoCave'))
                ->endkey(array('NegoCave', array()))
                ->executeView('ACHAT', 'qualite');

        $acheteurs_negociant = array();
        $acheteurs_cave = array();
        $acheteurs_mout = array();
        foreach ($cooperatives as $key => $value) {
            $acheteurs_cave[$value->cvi]['cvi'] = $value->cvi;
            $acheteurs_cave[$value->cvi]['commune'] = $value->commune;
            $acheteurs_cave[$value->cvi]['nom'] = $value->nom;

            $acheteurs_mout[$value->cvi]['cvi'] = $value->cvi;
            $acheteurs_mout[$value->cvi]['commune'] = $value->commune;
            $acheteurs_mout[$value->cvi]['nom'] = $value->nom;
        }
        foreach ($negociants as $key => $value) {
            $acheteurs_negociant[$value->cvi]['cvi'] = $value->cvi;
            $acheteurs_negociant[$value->cvi]['commune'] = $value->commune;
            $acheteurs_negociant[$value->cvi]['nom'] = $value->nom;

            $acheteurs_mout[$value->cvi]['cvi'] = $value->cvi;
            $acheteurs_mout[$value->cvi]['commune'] = $value->commune;
            $acheteurs_mout[$value->cvi]['nom'] = $value->nom;
        }

        foreach ($negocaves as $key => $value) {
            $acheteurs_negociant[$value->cvi]['cvi'] = $value->cvi;
            $acheteurs_negociant[$value->cvi]['commune'] = $value->commune;
            $acheteurs_negociant[$value->cvi]['nom'] = $value->nom;

            $acheteurs_mout[$value->cvi]['cvi'] = $value->cvi;
            $acheteurs_mout[$value->cvi]['commune'] = $value->commune;
            $acheteurs_mout[$value->cvi]['nom'] = $value->nom;
        }

        uasort($acheteurs_negociant, 'AcheteurClient::sortByNom');
        uasort($acheteurs_mout, 'AcheteurClient::sortByNom');

        $acheteurs = array();
        $acheteurs['negoces'] = $acheteurs_negociant;
        $acheteurs['cooperatives'] = $acheteurs_cave;
        $acheteurs['mouts'] = $acheteurs_mout;
        return $acheteurs;
    }

    public function retrieveByCvi($cvi, $hydrate = sfCouchdbClient::HYDRATE_DOCUMENT) {
        return parent::retrieveDocumentById('ACHAT-' . $cvi, $hydrate);
    }

    public static function sortByNom($a, $b) {
        return strcmp($a['nom'], $b['nom']);
    }

    protected function loadAcheteursList($type) {
        if (is_null($this->_acheteurs)) {
            $this->_acheteurs = CacheFunction::cache('model', array($this, 'loadAcheteurs'), array(), 31556926);
        }

        return $this->_acheteurs[$type];
    }

    public function getNegoces() {
        return $this->loadAcheteursList('negoces');
    }

    public function getCooperatives() {
        return $this->loadAcheteursList('cooperatives');
    }

    public function getMouts() {
        return $this->loadAcheteursList('mouts');
    }

}

{'fraction_non_alphanumeric': 0.17695944977790515, 'fraction_numerical': 0.00802407221664995, 'mean_word_length': 2.8542241855328547, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 117, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, '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': '4737733', 'n_tokens_mistral': 2431, 'n_tokens_neox': 2320, 'n_words': 308}