<commit_before><?php

namespace CodeDay\Clear\Commands\Jobs;

use \Carbon\Carbon;
use \CodeDay\Clear\Models;
use \CodeDay\Clear\Services;

class SendRMEventStatusJob {
    public $interval = '1 day';
    public function fire()
    {
        if (Models\Batch::Loaded()->starts_at->isPast()) { return; } // Don't send emails once the event has started

        $interval = (Models\Batch::Loaded()->starts_at->addWeeks(-2)->isPast()) ? 'daily' : 'weekly';
        $cronjob = Models\Cronjob::where('class', '=', '\\CodeDay\\Clear\\Commands\\Jobs\\'.__CLASS__)->first();
        $last_run = $cronjob ? $cronjob->updated_at : Carbon::createFromTimestamp(0);

        if ($interval === 'weekly' && ($last_run->addDays(5)->isFuture() || Carbon::now()->dayOfWeek != 1)) {
            echo "Skipping - set to run weekly; too recent or not current Monday\n";
            return;
        }

        $emailEvents = Models\Batch\Event
            ::select('batches_events.*')
            ->where('batch_id', '=', Models\Batch::Loaded()->id)
            ->whereNotNull('manager_username')
            ->groupBy('manager_username')
            ->get();

        $leaderboard = iterator_to_array(Models\Batch\Event
            ::where('batch_id', '=', Models\Batch::Loaded()->id)
            ->get()
        );

        usort($leaderboard, function($a, $b) {
            return count($b->registrations_this_week) - count($a->registrations_this_week);
        });

        foreach ($emailEvents as $event) {<commit_msg>Fix weekly RM event status email<commit_after><?php

namespace CodeDay\Clear\Commands\Jobs;

use \Carbon\Carbon;
use \CodeDay\Clear\Models;
use \CodeDay\Clear\Services;

class SendRMEventStatusJob {
    public $interval = '1 day';
    public function fire()
    {
        if (Models\Batch::Loaded()->starts_at->isPast()) { return; } // Don't send emails once the event has started

        $interval = (Models\Batch::Loaded()->starts_at->addWeeks(-2)->isPast()) ? 'daily' : 'weekly';
        $cronjob = Models\Cronjob::where('class', '=', '\\CodeDay\\Clear\\Commands\\Jobs\\'.__CLASS__)->first();
        $last_run = $cronjob ? $cronjob->updated_at : Carbon::createFromTimestamp(0);

        if ($interval === 'weekly' && (Carbon::now()->dayOfWeek != 1)) {
            echo "Skipping - set to run weekly; not currently Monday\n";
            return;
        }

        $emailEvents = Models\Batch\Event
            ::select('batches_events.*')
            ->where('batch_id', '=', Models\Batch::Loaded()->id)
            ->whereNotNull('manager_username')
            ->groupBy('manager_username')
            ->get();

        $leaderboard = iterator_to_array(Models\Batch\Event
            ::where('batch_id', '=', Models\Batch::Loaded()->id)
            ->get()
        );

        usort($leaderboard, function($a, $b) {
            return count($b->registrations_this_week) - count($a->registrations_this_week);
        });

        foreach ($emailEvents as $event) {
{'fraction_non_alphanumeric': 0.1746298788694482, 'fraction_numerical': 0.003028263795423957, 'mean_word_length': 2.6749072929542645, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 39, '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': '921238', 'n_tokens_mistral': 930, 'n_tokens_neox': 898, 'n_words': 165}