<commit_before><?php

namespace App;

use Respect\Validation\Validator;

use Movim\Picture;
use Movim\User;

use Illuminate\Database\Eloquent\Model;

class Post extends Model
{
    protected $primaryKey = 'id';

    protected $guarded = [];
    private $titleLimit = 200;

    public $attachments = [];
    public $tags = [];

    public function contact()
    {
        return $this->hasOne('App\Contact', 'id', 'aid');
    }

    public function tags()
    {
        return $this->belongsToMany('App\Tag')->withTimestamps();
    }

    public function comments()
    {
        return $this->hasMany('App\Post', 'parent_id', 'id')
                    ->where('like', false);
    }

    public function likes()
    {
        return $this->hasMany('App\Post', 'parent_id', 'id')
                    ->where('like', true);
    }

    public function attachments()
    {
        return $this->hasMany('App\Attachment');
    }

    public function save(array $options = [])
    {
        try {
            parent::save($options);

            $this->attachments()->delete();
            $this->attachments()->saveMany($this->attachments);
            $this->tags()->sync($this->tags);
        } catch (\Exception $e) {
            /*
             * When an article is received by two accounts simultaenously
             * in different processes they can be saved using the insert state
             * in the DB causing an error
             */
        }<commit_msg>Fix the ordering of comments<commit_after><?php

namespace App;

use Respect\Validation\Validator;

use Movim\Picture;
use Movim\User;

use Illuminate\Database\Eloquent\Model;

class Post extends Model
{
    protected $primaryKey = 'id';

    protected $guarded = [];
    private $titleLimit = 200;

    public $attachments = [];
    public $tags = [];

    public function contact()
    {
        return $this->hasOne('App\Contact', 'id', 'aid');
    }

    public function tags()
    {
        return $this->belongsToMany('App\Tag')->withTimestamps();
    }

    public function comments()
    {
        return $this->hasMany('App\Post', 'parent_id', 'id')
                    ->orderBy('published')
                    ->where('like', false);
    }

    public function likes()
    {
        return $this->hasMany('App\Post', 'parent_id', 'id')
                    ->where('like', true);
    }

    public function attachments()
    {
        return $this->hasMany('App\Attachment');
    }

    public function save(array $options = [])
    {
        try {
            parent::save($options);

            $this->attachments()->delete();
            $this->attachments()->saveMany($this->attachments);
            $this->tags()->sync($this->tags);
        } catch (\Exception $e) {
            /*
             * When an article is received by two accounts simultaenously
             * in different processes they can be saved using the insert state
             * in the DB causing an error
             */
        }
{'fraction_non_alphanumeric': 0.14017437961099932, 'fraction_numerical': 0.002012072434607646, 'mean_word_length': 2.0284263959390865, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 36, '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': '1487453', 'n_tokens_mistral': 844, 'n_tokens_neox': 815, 'n_words': 205}