<commit_before><?php

namespace App\Component;

abstract class BaseDatagridComponent extends BaseComponent
{
    /** @var \Nextras\Datagrid\Datagrid */
    protected $grid;

    /** @var \App\Model\BaseModel */
    protected $model;

    /** @var int */
    protected $perPage;

    public function attached($presenter)
    {
        $this->perPage = $presenter->getUser()->getIdentity()->per_page;
    }

    public function createComponentDataGrid()
    {
        if ($this->grid === null)
        {
            $this->grid = new \Nextras\Datagrid\Datagrid;
        }
        $this->grid->addCellsTemplate(__DIR__.'/Paginator.latte');
        $this->grid->addCellsTemplate(__DIR__.'/TableTag.latte');
        $this->grid->setDataSourceCallback(array($this, 'dataSource'));
        $this->grid->setPagination($this->perPage, array($this, 'dataSourceCount'));
    }

    public function getDataSource($filter, $order)
    {
        $filters = array();
        foreach ($filter as $k => $v) {
            if ($k == 'id' || is_array($v))
                $filters[$k] = $v;
            else
                $filters[$k. ' LIKE ?'] = "%$v%";
        }

        $set = $this->model->findByArray($filters);
        if ($order[0])
        {
            $set->order(implode(' ', $order));
        }
        return $set;
    }

    public function dataSource($filter, $order, \Nette\Utils\Paginator $paginator = null)
    {
        return $this->getDataSource($filter, $order)->limit($paginator->getItemsPerPage(), $paginator->getOffset());
    }

    public function dataSourceCount($filter, $order)
    {
        return $this->getDataSource($filter, $order)->count('*');
    }
}
<commit_msg>cosmetic change<commit_after><?php

namespace App\Component;

abstract class BaseDatagridComponent extends BaseComponent
{
    /** @var \Nextras\Datagrid\Datagrid */
    protected $grid;

    /** @var \App\Model\BaseModel */
    protected $model;

    /** @var int */
    protected $perPage;

    public function attached($presenter)
    {
        $this->perPage = $presenter->getUser()->getIdentity()->per_page;
    }

    public function createComponentDataGrid()
    {
        if ($this->grid === null)
        {
            $this->grid = new \Nextras\Datagrid\Datagrid;
        }
        $this->grid->addCellsTemplate(__DIR__.'/Paginator.latte');
        $this->grid->addCellsTemplate(__DIR__.'/TableTag.latte');
        $this->grid->setDataSourceCallback(array($this, 'dataSource'));
        $this->grid->setPagination($this->perPage, array($this, 'dataSourceCount'));
    }

    public function getDataSource($filter, $order)
    {
        $filters = array();
        foreach ($filter as $k => $v) {
            if ($k == 'id' || is_array($v))
                $filters[$k] = $v;
            else
                $filters[$k. ' LIKE ?'] = "%$v%";
        }

        $set = $this->model->findByArray($filters);

        if ($order[0])
        {
            $set->order(implode(' ', $order));
        }
        return $set;
    }

    public function dataSource($filter, $order, \Nette\Utils\Paginator $paginator = null)
    {
        return $this->getDataSource($filter, $order)->limit($paginator->getItemsPerPage(), $paginator->getOffset());
    }

    public function dataSourceCount($filter, $order)
    {
        return $this->getDataSource($filter, $order)->count('*');
    }
}

{'fraction_non_alphanumeric': 0.17027588252743994, 'fraction_numerical': 0.0005932957579353308, 'mean_word_length': 2.4026236125126137, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 53, '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': '4725247', 'n_tokens_mistral': 1036, 'n_tokens_neox': 1013, 'n_words': 177}