<commit_before><?php namespace CoandaCMS\ContentSignoff\Repositories\Eloquent;

use CoandaCMS\ContentSignoff\Repositories\ContentSignoffRepositoryInterface;
use CoandaCMS\ContentSignoff\Repositories\Eloquent\Models\SignoffRequest;

class EloquentContentSignoffRepository implements ContentSignoffRepositoryInterface {

    /**
     * @var SignoffRequest
     */
    private $signoff_request_model;

    /**
     * @param SignoffRequest $signoff_request_model
     */
    public function __construct(SignoffRequest $signoff_request_model)
    {
        $this->signoff_request_model = $signoff_request_model;
    }

    /**
     * @param $version_id
     * @param $version_number
     * @param $page_id
     * @param $page_name
     * @param $requester_id
     * @return mixed
     */
    public function createNewSignoffRequest($version_id, $version_number, $page_id, $page_name, $requester_id)
    {
        return $this->signoff_request_model->create([
            'version_id' => $version_id,
            'version' => $version_number,
            'page_id' => $page_id,
            'page_name' => $page_name,
            'requested_by' => $requester_id,
            'status' => 'pending'
        ]);
    }

    /**
     * @param $id
     * @return mixed
     */
    public function getById($id)
    {
        return $this->signoff_request_model->find($id);
    }

    /**
     * @param $per_page
     * @return mixed
     */
    public function pending($per_page)
    {
        return $this->signoff_request_model->whereStatus('pending')->paginate($per_page);
    }

    /**
     * @param $per_page
     * @return mixed
     */
    public function history($per_page)
    {
        return $this->signoff_request_model->where('status', '<>', 'pending')->orderBy('updated_at', 'desc')->paginate($per_page);
    }
}<commit_msg>Default to ordering the pending requests by the most recent first.<commit_after><?php namespace CoandaCMS\ContentSignoff\Repositories\Eloquent;

use CoandaCMS\ContentSignoff\Repositories\ContentSignoffRepositoryInterface;
use CoandaCMS\ContentSignoff\Repositories\Eloquent\Models\SignoffRequest;

class EloquentContentSignoffRepository implements ContentSignoffRepositoryInterface {

    /**
     * @var SignoffRequest
     */
    private $signoff_request_model;

    /**
     * @param SignoffRequest $signoff_request_model
     */
    public function __construct(SignoffRequest $signoff_request_model)
    {
        $this->signoff_request_model = $signoff_request_model;
    }

    /**
     * @param $version_id
     * @param $version_number
     * @param $page_id
     * @param $page_name
     * @param $requester_id
     * @return mixed
     */
    public function createNewSignoffRequest($version_id, $version_number, $page_id, $page_name, $requester_id)
    {
        return $this->signoff_request_model->create([
            'version_id' => $version_id,
            'version' => $version_number,
            'page_id' => $page_id,
            'page_name' => $page_name,
            'requested_by' => $requester_id,
            'status' => 'pending'
        ]);
    }

    /**
     * @param $id
     * @return mixed
     */
    public function getById($id)
    {
        return $this->signoff_request_model->find($id);
    }

    /**
     * @param $per_page
     * @return mixed
     */
    public function pending($per_page)
    {
        return $this->signoff_request_model->whereStatus('pending')->orderBy('created_at', 'desc')->paginate($per_page);
    }

    /**
     * @param $per_page
     * @return mixed
     */
    public function history($per_page)
    {
        return $this->signoff_request_model->where('status', '<>', 'pending')->orderBy('updated_at', 'desc')->paginate($per_page);
    }
}
{'fraction_non_alphanumeric': 0.12640599892876273, 'fraction_numerical': 0.0, 'mean_word_length': 2.811224489795918, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 42, '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': '1120661', 'n_tokens_mistral': 1165, 'n_tokens_neox': 1153, 'n_words': 183}