<commit_before><?php
namespace CodeDay\Clear\Models\Batch;

use \Illuminate\Database\Eloquent;
use \CodeDay\Clear\Models;
use \Carbon\Carbon;

/**
 * Class Event
 * @package CodeDay\Clear\Models\Batch
 *
 * @property Models\SigningRequest  $signing_request
 * @property string                 $agreement_signed_url;
 */
class Event extends \Eloquent {
    public function getAllowRegistrationsCalculatedAttribute()
    {
        return $this->allow_registrations && $this->batch->allow_registrations;
    }

    public function getSignatureAttribute()
    {
        return hash_hmac('sha256', \Config::get('app.key'), $this->id);
    }

    public function getFullNameAttribute()
    {
        return 'CodeDay '.$this->name.' '.$this->batch->name;
    }

    public function getBatchNameAttribute()
    {
        return $this->batch->name;
    }

    public function getStartsAtAttribute()
    {
        return Carbon::createFromTimestamp($this->batch->starts_at->timestamp, $this->region->timezone)
                    ->addHours(12)
                    ->timestamp;
    }

    public function getEndsAtAttribute()
    {
        return $this->starts_at + (60 * 60 * 24);
    }

    public function getPreviousAttribute()
    {
        if (!$this->batch->previous) {
            return null;
        }

        return self
            ::where('region_id', '=', $this->region_id)
            ->where('batch_id', '=', $this->batch->previous->id)
            ->first();
    }

    public function overflowFor()
    {
        return $this->belongsTo('\CodeDay\Clear\Models\Batch\Event', 'overflow_for_id', 'id');
    }

    public function overflowEvents()
    {
        return $this->hasMany('\CodeDay\Clear\Models\Batch\Event', 'overflow_for_id', 'id');
    }

    public function getRelatedEventsAttribute()
    {
        if ($this->overflow_for_id !== null) {
            $parent_related = iterator_to_array($this->overflowFor->relatedEvents);
            $id = $this->id;
            $parent_related = array_filter($parent_related, function($event) use ($id) {
                return $id !== $event->id;
            });

            return array_merge([$this->overflowFor], $parent_related);
        } else {
            return $this->overflowEvents;
        }
    }

    public function getShipByAttribute()
    {
        $shipDate = $this->batch->starts_at->addDays(-1);<commit_msg>Fix weird overflow_for bug<commit_after><?php
namespace CodeDay\Clear\Models\Batch;

use \Illuminate\Database\Eloquent;
use \CodeDay\Clear\Models;
use \Carbon\Carbon;

/**
 * Class Event
 * @package CodeDay\Clear\Models\Batch
 *
 * @property Models\SigningRequest  $signing_request
 * @property string                 $agreement_signed_url;
 */
class Event extends \Eloquent {
    public function getAllowRegistrationsCalculatedAttribute()
    {
        return $this->allow_registrations && $this->batch->allow_registrations;
    }

    public function getSignatureAttribute()
    {
        return hash_hmac('sha256', \Config::get('app.key'), $this->id);
    }

    public function getFullNameAttribute()
    {
        return 'CodeDay '.$this->name.' '.$this->batch->name;
    }

    public function getBatchNameAttribute()
    {
        return $this->batch->name;
    }

    public function getStartsAtAttribute()
    {
        return Carbon::createFromTimestamp($this->batch->starts_at->timestamp, $this->region->timezone)
                    ->addHours(12)
                    ->timestamp;
    }

    public function getEndsAtAttribute()
    {
        return $this->starts_at + (60 * 60 * 24);
    }

    public function getPreviousAttribute()
    {
        if (!$this->batch->previous) {
            return null;
        }

        return self
            ::where('region_id', '=', $this->region_id)
            ->where('batch_id', '=', $this->batch->previous->id)
            ->first();
    }

    public function getOverflowForAttribute()                                                       
    {                                                                                               
        return self::where('id', '=', $this->overflow_for_id)->first();                             
    }

    public function overflowEvents()
    {
        return $this->hasMany('\CodeDay\Clear\Models\Batch\Event', 'overflow_for_id', 'id');
    }

    public function getRelatedEventsAttribute()
    {
        if ($this->overflow_for_id !== null) {
            $parent_related = iterator_to_array($this->overflowFor->relatedEvents);
            $id = $this->id;
            $parent_related = array_filter($parent_related, function($event) use ($id) {
                return $id !== $event->id;
            });

            return array_merge([$this->overflowFor], $parent_related);
        } else {
            return $this->overflowEvents;
        }
    }

    public function getShipByAttribute()
    {
        $shipDate = $this->batch->starts_at->addDays(-1);
{'fraction_non_alphanumeric': 0.13451827913552816, 'fraction_numerical': 0.004847505554433448, 'mean_word_length': 2.132194813409235, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 78, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2942546', 'n_tokens_mistral': 1426, 'n_tokens_neox': 1378, 'n_words': 243}