<commit_before>use MooseX::Declare;

use 5.010;

class Artemis::MCP::Scheduler::PrioQueue
{
        use Artemis::Exception::Param;

        use Artemis::Model 'model';
        use aliased 'Artemis::Schema::TestrunDB::Result::TestrunScheduling';

        method _max_seq {
                my $job_with_max_seq = model('TestrunDB')->resultset('TestrunScheduling')->search
                    (
                     { prioqueue_seq => { '>', 0 } },
                     {
                      select => [ { max => 'prioqueue_seq' } ],
                      as     => [ 'max_seq' ], }
                    )->first;
                return $job_with_max_seq->get_column('max_seq')
                  if defined $job_with_max_seq->get_column('max_seq');
                return 0;
        }

        method add($job, $is_subtestrun?)
        {
                my $max_seq = $self->_max_seq;
                $job->prioqueue_seq($max_seq + 1);
                $job->update;
        }

        method get_testrequests # get_jobs
        {
                no strict 'refs';
                my $testrequests_rs = model('TestrunDB')->resultset('TestrunScheduling')->search
                    ({
                      prioqueue_seq => { '>', 0 }
                     },
                     {
                      order_by => 'prioqueue_seq'
                     }
                    );
                return $testrequests_rs;
        }

        method get_first_fitting($free_hosts) {<commit_msg>MCP: get rid of an undef warning<commit_after>use MooseX::Declare;

use 5.010;

class Artemis::MCP::Scheduler::PrioQueue
{
        use Artemis::Exception::Param;

        use Artemis::Model 'model';
        use aliased 'Artemis::Schema::TestrunDB::Result::TestrunScheduling';

        method _max_seq {
                my $job_with_max_seq = model('TestrunDB')->resultset('TestrunScheduling')->search
                    (
                     { prioqueue_seq => { '>', 0 } },
                     {
                      select => [ { max => 'prioqueue_seq' } ],
                      as     => [ 'max_seq' ], }
                    )->first;
                return $job_with_max_seq->get_column('max_seq')
                  if $job_with_max_seq and defined $job_with_max_seq->get_column('max_seq');
                return 0;
        }

        method add($job, $is_subtestrun?)
        {
                my $max_seq = $self->_max_seq;
                $job->prioqueue_seq($max_seq + 1);
                $job->update;
        }

        method get_testrequests # get_jobs
        {
                no strict 'refs';
                my $testrequests_rs = model('TestrunDB')->resultset('TestrunScheduling')->search
                    ({
                      prioqueue_seq => { '>', 0 }
                     },
                     {
                      order_by => 'prioqueue_seq'
                     }
                    );
                return $testrequests_rs;
        }

        method get_first_fitting($free_hosts) {
{'fraction_non_alphanumeric': 0.11749087288416861, 'fraction_numerical': 0.005310321938267508, 'mean_word_length': 1.2920152091254753, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6186644', 'n_tokens_mistral': 899, 'n_tokens_neox': 807, 'n_words': 128}