<commit_before><?php
// echo "<pre>";
// var_dump($builds);
// echo "</pre>";

$maxbuildcount = 5;
$projects      = array();
$prevBuild     = null;
$health        = false;

foreach($builds as $build):

    if ($build->getStatus() < 2) {
        continue;
    }

    if ( is_null($prevBuild) || $build->getProjectId() !== $prevBuild->getProjectId() ) {
        $health = false;
        $projects[$build->getProjectId()]['count'] = 0;
        $projects[$build->getProjectId()]['health'] = 0;
        $projects[$build->getProjectId()]['successes'] = 0;
        $projects[$build->getProjectId()]['failures'] = 0;
        $projects[$build->getProjectId()]['lastbuildstatus'] = (int)$build->getStatus();
    }

    if (
        !is_null($prevBuild) &&
        $projects[$build->getProjectId()]['count'] >= $maxbuildcount &&
        $build->getProjectId() === $prevBuild->getProjectId()
    ) {
        $projects[$build->getProjectId()]['count']++;
        continue;
    }

    switch ((int)$build->getStatus()) {
        case 2:
            $projects[$build->getProjectId()]['health']++;
            $projects[$build->getProjectId()]['successes']++;

            if ( empty($projects[$build->getProjectId()]['lastsuccess']) ) {
                $projects[$build->getProjectId()]['lastsuccess'] = $build;
            }
            break;
        case 3:
            $projects[$build->getProjectId()]['health']--;
            $projects[$build->getProjectId()]['failures']++;

            if ( empty($projects[$build->getProjectId()]['lastfailure']) ) {
                $projects[$build->getProjectId()]['lastfailure'] = $build;
            }
            break;
    }

    $projects[$build->getProjectId()]['count']++;
    $projects[$build->getProjectId()]['projectname'] = $build->getProject()->getTitle();
    $prevBuild = $build;
endforeach;

foreach($projects as $projectId => $project):
    switch($project['lastbuildstatus'])
    {
        case 0:
            $cls = 'info';
            $status = 'Pending';
        break;

        case 1:
            $cls = 'warning';
            $status = 'Running';
        break;

        case 2:
            $cls = 'success';
            $status = 'Success';
        break;

        case 3:
            $cls = 'error';
            $status = 'Failed';
        break;
    }

    $health = ($project['health'] < 0 ? 'Stormy': ($project['health'] < 5? 'Overcast': 'Sunny'));
    $subcls = ($project['health'] < 0 ? 'important': ($project['health'] < 5? 'warning': 'success'));
?>
<tr class="<?php print $cls; ?>">
    <td>
        <span class='label label-<?= $subcls ?>'>
            <?= $health ?>
        </span>
    </td>
    <td><a href='<?= PHPCI_URL ?>project/view/<?= $projectId ?>'><?= $project['projectname'] ?></a></td>
    <td>
        <?php if (empty($project['lastsuccess'])) {
            echo "Never";
        } else { ?>
            <a href='<?= PHPCI_URL ?>build/view/<?= $project['lastsuccess']->getId() ?>'>
            <?= $project['lastsuccess']->getStarted()->format("Y-m-d H:i:s") ?>
            </a>
        <?php } ?>
    </td>
    <td>
        <?php if (empty($project['lastfailure'])) {
            echo "Never";
        } else { ?>
            <a href='<?= PHPCI_URL ?>build/view/<?= $project['lastfailure']->getId() ?>'>
            <?= $project['lastfailure']->getStarted()->format("Y-m-d H:i:s") ?>
            </a>
        <?php } ?>
    </td>
    <td><?= $project['successes'] ?>/<?= $project['failures'] ?></td>
    <td><a href='<?= PHPCI_URL ?>project/build/<?= $projectId ?>'>build</a></td>
</tr>
<?php endforeach; ?><commit_msg>added class to make button like other buttons on the site<commit_after><?php
// echo "<pre>";
// var_dump($builds);
// echo "</pre>";

$maxbuildcount = 5;
$projects      = array();
$prevBuild     = null;
$health        = false;

foreach($builds as $build):

    if ($build->getStatus() < 2) {
        continue;
    }

    if ( is_null($prevBuild) || $build->getProjectId() !== $prevBuild->getProjectId() ) {
        $health = false;
        $projects[$build->getProjectId()]['count'] = 0;
        $projects[$build->getProjectId()]['health'] = 0;
        $projects[$build->getProjectId()]['successes'] = 0;
        $projects[$build->getProjectId()]['failures'] = 0;
        $projects[$build->getProjectId()]['lastbuildstatus'] = (int)$build->getStatus();
    }

    if (
        !is_null($prevBuild) &&
        $projects[$build->getProjectId()]['count'] >= $maxbuildcount &&
        $build->getProjectId() === $prevBuild->getProjectId()
    ) {
        $projects[$build->getProjectId()]['count']++;
        continue;
    }

    switch ((int)$build->getStatus()) {
        case 2:
            $projects[$build->getProjectId()]['health']++;
            $projects[$build->getProjectId()]['successes']++;

            if ( empty($projects[$build->getProjectId()]['lastsuccess']) ) {
                $projects[$build->getProjectId()]['lastsuccess'] = $build;
            }
            break;
        case 3:
            $projects[$build->getProjectId()]['health']--;
            $projects[$build->getProjectId()]['failures']++;

            if ( empty($projects[$build->getProjectId()]['lastfailure']) ) {
                $projects[$build->getProjectId()]['lastfailure'] = $build;
            }
            break;
    }

    $projects[$build->getProjectId()]['count']++;
    $projects[$build->getProjectId()]['projectname'] = $build->getProject()->getTitle();
    $prevBuild = $build;
endforeach;

foreach($projects as $projectId => $project):
    switch($project['lastbuildstatus'])
    {
        case 0:
            $cls = 'info';
            $status = 'Pending';
        break;

        case 1:
            $cls = 'warning';
            $status = 'Running';
        break;

        case 2:
            $cls = 'success';
            $status = 'Success';
        break;

        case 3:
            $cls = 'error';
            $status = 'Failed';
        break;
    }

    $health = ($project['health'] < 0 ? 'Stormy': ($project['health'] < 5? 'Overcast': 'Sunny'));
    $subcls = ($project['health'] < 0 ? 'important': ($project['health'] < 5? 'warning': 'success'));
?>
<tr class="<?php print $cls; ?>">
    <td>
        <span class='label label-<?= $subcls ?>'>
            <?= $health ?>
        </span>
    </td>
    <td><a href='<?= PHPCI_URL ?>project/view/<?= $projectId ?>'><?= $project['projectname'] ?></a></td>
    <td>
        <?php if (empty($project['lastsuccess'])) {
            echo "Never";
        } else { ?>
            <a href='<?= PHPCI_URL ?>build/view/<?= $project['lastsuccess']->getId() ?>'>
            <?= $project['lastsuccess']->getStarted()->format("Y-m-d H:i:s") ?>
            </a>
        <?php } ?>
    </td>
    <td>
        <?php if (empty($project['lastfailure'])) {
            echo "Never";
        } else { ?>
            <a href='<?= PHPCI_URL ?>build/view/<?= $project['lastfailure']->getId() ?>'>
            <?= $project['lastfailure']->getStarted()->format("Y-m-d H:i:s") ?>
            </a>
        <?php } ?>
    </td>
    <td><?= $project['successes'] ?>/<?= $project['failures'] ?></td>
    <td><a class="btn" href='<?= PHPCI_URL ?>project/build/<?= $projectId ?>'>build</a></td>
</tr>
<?php endforeach; ?>
{'fraction_non_alphanumeric': 0.2266206896551724, 'fraction_numerical': 0.004413793103448276, 'mean_word_length': 2.3662952646239552, 'pattern_counts': {'":': 0, '<': 109, '<?xml version=': 0, '>': 167, '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': '3369964', 'n_tokens_mistral': 2277, 'n_tokens_neox': 2236, 'n_words': 383}