<commit_before><?php
class ComLanguagesDatabaseBehaviorTranslatable extends KDatabaseBehaviorAbstract
{
    protected function _beforeTableSelect(KCommandContext $context)
    {
        $application = $this->getService('application');
        if($application->getCfg('multilanguage') && $query = $context->query)
        {
            $tables = $this->getService('com://admin/languages.model.tables')
                ->enabled(true)
                ->getList();
            
            if(is_string(current($query->table)))
            {
                $table = $tables->find(array('name' => current($query->table)));
                
                if(count($table))
                {
                    $table = $table->top();
                    
                    // Join translation to add status to rows.
                    if(!$query->isCountQuery() && isset($context->options->state->translation))
                    {
                        $query->columns(array('translation' => 'translations.status'))
                            ->join(array('translations' => 'languages_translations'),
                                'translations.table = :translation_table AND translations.row = tbl.'.$table->unique_column)
                            ->bind(array('translation_table' => $table->name));
                        
                        if(!is_null($context->options->state->translation))
                        {
                            $query->where('translations.status IN :translation')
                                ->bind(array('translation_status' => (array) $context->options->state->translation));
                        }
                    }
                    
                    $languages = $application->getLanguages();
                    $active    = $languages->getActive();
                    $primary   = $languages->getPrimary();
                    <commit_msg>Add iso_code to join. re #215<commit_after><?php
class ComLanguagesDatabaseBehaviorTranslatable extends KDatabaseBehaviorAbstract
{
    protected function _beforeTableSelect(KCommandContext $context)
    {
        $application = $this->getService('application');
        if($application->getCfg('multilanguage') && $query = $context->query)
        {
            $tables = $this->getService('com://admin/languages.model.tables')
                ->enabled(true)
                ->getList();
            
            if(is_string(current($query->table)))
            {
                $table = $tables->find(array('name' => current($query->table)));
                
                if(count($table))
                {
                    $table     = $table->top();
                    $languages = $application->getLanguages();
                    $active    = $languages->getActive();
                    $primary   = $languages->getPrimary();
                    
                    // Join translation to add status to rows.
                    if(!$query->isCountQuery() && isset($context->options->state->translation))
                    {
                        $query->columns(array('translation' => 'translations.status'))
                            ->join(array('translations' => 'languages_translations'),
                                'translations.iso_code = :translation_iso_code AND translations.table = :translation_table AND translations.row = tbl.'.$table->unique_column)
                            ->bind(array(
                                'translation_iso_code' => $active->iso_code,
                                'translation_table' => $table->name
                            ));
                        
                        if(!is_null($context->options->state->translation))
                        {
                            $query->where('translations.status IN :translation')
                                ->bind(array('translation_status' => (array) $context->options->state->translation));
                        }
                    }
                    
                    
                    
{'fraction_non_alphanumeric': 0.12506142506142506, 'fraction_numerical': 0.0007371007371007371, 'mean_word_length': 1.3383113153360138, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 75, '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': '3526423', 'n_tokens_mistral': 930, 'n_tokens_neox': 880, 'n_words': 127}