<commit_before><?php 

namespace Qik\Database;

class DBRepository extends DBQuery
{
    public $pagination = false;
    public $paginationPage = 0;
    public $paginationSize = 0;
    public $queryTotalRows = null;

    public function setPagination($paginationParams)
    {
        if (!empty($paginationParams)) {
            $this->pagination = true;
            $this->paginationPage = $paginationParams['_page'];
            $this->paginationSize = $paginationParams['_pageSize'];
        }
    }

    public function getPaginationData()
    {
        return [
            '_page' => $this->paginationPage,
            '_pageSize' => $this->paginationSize,
            '_totalPages' => ceil($this->queryTotalRows / $this->paginationSize),
            '_totalRows' => $this->queryTotalRows
        ];
    }

    public function addPagination($dbq) 
    {
        if ($this->pagination) {
            $this->queryTotalRows = $dbq->count();
            $offset = ($this->paginationPage - 1)  * $this->paginationSize;
            $dbq->offset($offset);            
            $dbq->limit($this->paginationSize);
        }

        return $dbq;
    }<commit_msg>optionally passing row count will skip the count call<commit_after><?php 

namespace Qik\Database;

class DBRepository extends DBQuery
{
    public $pagination = false;
    public $paginationPage = 0;
    public $paginationSize = 0;
    public $queryTotalRows = null;

    public function setPagination($paginationParams)
    {
        if (!empty($paginationParams)) {
            $this->pagination = true;
            $this->paginationPage = $paginationParams['_page'];
            $this->paginationSize = $paginationParams['_pageSize'];
        }
    }

    public function getPaginationData()
    {
        return [
            '_page' => $this->paginationPage,
            '_pageSize' => $this->paginationSize,
            '_totalPages' => ceil($this->queryTotalRows / $this->paginationSize),
            '_totalRows' => $this->queryTotalRows
        ];
    }

    public function addPagination($dbq, $queryTotalRows = null)
    {
        if ($this->pagination) {
            if (is_null($queryTotalRows))
                $this->queryTotalRows = $dbq->count();
            else
                $this->queryTotalRows = $queryTotalRows;

            $offset = ($this->paginationPage - 1)  * $this->paginationSize;
            $dbq->offset($offset);            
            $dbq->limit($this->paginationSize);
        }

        return $dbq;
    }
{'fraction_non_alphanumeric': 0.12898089171974522, 'fraction_numerical': 0.0023885350318471337, 'mean_word_length': 2.161006289308176, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 44, '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': '1337079', 'n_tokens_mistral': 722, 'n_tokens_neox': 706, 'n_words': 131}