<commit_before><?php namespace App\Http\Controllers;

use Lang;
use Input;
use App\Project;
use App\Deployment;
use App\Http\Controllers\Controller;
use App\Repositories\Contracts\DeploymentRepositoryInterface;
use App\Commands\QueueDeployment;

/**
 * The controller for showing the status of deployments
 */
class DeploymentController extends Controller
{
    /**
     * The details of an individual project
     *
     * @param Project $project
     * @param DeploymentRepositoryInterface $deploymentRepository
     * @return View
     */
    public function project(Project $project, DeploymentRepositoryInterface $deploymentRepository)
    {
        $optional = $project->commands->filter(function ($command) {
            return $command->optional;
        });

        return view('projects.details', [
            'title'         => $project->name,
            'deployments'   => $deploymentRepository->getLatest($project),
            'today'         => $deploymentRepository->getTodayCount($project),
            'last_week'     => $deploymentRepository->getLastWeekCount($project),
            'project'       => $project,
            'servers'       => $project->servers,
            'notifications' => $project->notifications,
            'notifyEmails'  => $project->notifyEmails,
            'heartbeats'    => $project->heartbeats,
            'sharedFiles'   => $project->shareFiles,
            'projectFiles'  => $project->projectFiles,
            'checkUrls'     => $project->checkUrls,
            'optional'      => $optional
        ]);
    }

    /**
     * Show the deployment details
     *
     * @param Deployment $deployment
     * @return Response
     */
    public function show(Deployment $deployment)
    {
        $output = [];
        foreach ($deployment->steps as $step) {
            foreach ($step->servers as $server) {
                $server->server;

                $server->runtime  = ($server->runtime() === false ? null : human_readable_duration($server->runtime()));
                $server->output   = ((is_null($server->output) || !strlen($server->output)) ? null : '');
                $server->script   = '';
                $server->first    = (count($output) === 0); // FIXME: Let backbone.js take care of this

                $output[] = $server;
            }
        }

        $project = $deployment->project;

        return view('deployment.details', [
            'breadcrumb' => [
                ['url' => url('projects', $project->id), 'label' => $project->name]
            ],
            'title'      => Lang::get('deployments.details'),
            'project'    => $project,
            'deployment' => $deployment,
            'output'     => $output
        ]);
    }

    /**
     * Adds a deployment for the specified project to the queue
     *
     * @param Project $project
     * @return Response
     * TODO: Don't allow this to run if there is already a pending deploy or no servers
     */
    public function deploy(Project $project)
    {
        $deployment = new Deployment;
        $deployment->reason = Input::get('reason');

        if (Input::has('source') && Input::has('source_' . Input::get('source'))) {
            $deployment->branch = Input::get('source_' . Input::get('source'));
        }

        if (empty($deployment->branch)) {
            $deployment->branch = $project->branch;
        }

        $optional = [];

        if (Input::has('optional')) {
            $optional = Input::get('optional');
        }

        $this->dispatch(new QueueDeployment(
            $project,
            $deployment,
            $optional
        ));

        return redirect()->route('deployment', [
            'id' => $deployment->id
        ]);
    }
}
<commit_msg>More typehinting<commit_after><?php namespace App\Http\Controllers;

use Lang;
use Input;
use App\Project;
use App\Command;
use App\Deployment;
use App\Http\Controllers\Controller;
use App\Repositories\Contracts\DeploymentRepositoryInterface;
use App\Commands\QueueDeployment;

/**
 * The controller for showing the status of deployments
 */
class DeploymentController extends Controller
{
    /**
     * The details of an individual project
     *
     * @param Project $project
     * @param DeploymentRepositoryInterface $deploymentRepository
     * @return View
     */
    public function project(Project $project, DeploymentRepositoryInterface $deploymentRepository)
    {
        $optional = $project->commands->filter(function (Command $command) {
            return $command->optional;
        });

        return view('projects.details', [
            'title'         => $project->name,
            'deployments'   => $deploymentRepository->getLatest($project),
            'today'         => $deploymentRepository->getTodayCount($project),
            'last_week'     => $deploymentRepository->getLastWeekCount($project),
            'project'       => $project,
            'servers'       => $project->servers,
            'notifications' => $project->notifications,
            'notifyEmails'  => $project->notifyEmails,
            'heartbeats'    => $project->heartbeats,
            'sharedFiles'   => $project->shareFiles,
            'projectFiles'  => $project->projectFiles,
            'checkUrls'     => $project->checkUrls,
            'optional'      => $optional
        ]);
    }

    /**
     * Show the deployment details
     *
     * @param Deployment $deployment
     * @return Response
     */
    public function show(Deployment $deployment)
    {
        $output = [];
        foreach ($deployment->steps as $step) {
            foreach ($step->servers as $server) {
                $server->server;

                $server->runtime  = ($server->runtime() === false ? null : human_readable_duration($server->runtime()));
                $server->output   = ((is_null($server->output) || !strlen($server->output)) ? null : '');
                $server->script   = '';
                $server->first    = (count($output) === 0); // FIXME: Let backbone.js take care of this

                $output[] = $server;
            }
        }

        $project = $deployment->project;

        return view('deployment.details', [
            'breadcrumb' => [
                ['url' => url('projects', $project->id), 'label' => $project->name]
            ],
            'title'      => Lang::get('deployments.details'),
            'project'    => $project,
            'deployment' => $deployment,
            'output'     => $output
        ]);
    }

    /**
     * Adds a deployment for the specified project to the queue
     *
     * @param Project $project
     * @return Response
     * TODO: Don't allow this to run if there is already a pending deploy or no servers
     */
    public function deploy(Project $project)
    {
        $deployment = new Deployment;
        $deployment->reason = Input::get('reason');

        if (Input::has('source') && Input::has('source_' . Input::get('source'))) {
            $deployment->branch = Input::get('source_' . Input::get('source'));
        }

        if (empty($deployment->branch)) {
            $deployment->branch = $project->branch;
        }

        $optional = [];

        if (Input::has('optional')) {
            $optional = Input::get('optional');
        }

        $this->dispatch(new QueueDeployment(
            $project,
            $deployment,
            $optional
        ));

        return redirect()->route('deployment', [
            'id' => $deployment->id
        ]);
    }
}

{'fraction_non_alphanumeric': 0.14232706069440762, 'fraction_numerical': 0.00026504108136761196, 'mean_word_length': 2.0358004827031375, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 117, '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': '2641396', 'n_tokens_mistral': 2016, 'n_tokens_neox': 1981, 'n_words': 424}