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

use App\Jobs\UpdateLiveCopy;
use App\Jobs\UpdateVersionHashes;

use App\Http\Requests\VersionUpdateRequest;

use Illuminate\Filesystem\Filesystem;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Inspiring;
use Illuminate\Http\Request;

class HooksController extends Controller
{
  use DispatchesJobs;

  public function specChange(Request $request)
  {
    switch ($request->header('x-github-event'))
    {
      case 'pull_request':
        // update jobs are only necessary on PR merges
        $json = json_decode($request->input('payload'), true);

        if ($json['action'] == 'closed' && $json['merged'])
        {
          $this->dispatch(new UpdateLiveCopy());
          $this->dispatch(new UpdateVersionHashes());
        }
        break;

      case 'push':
        // just initiate spec and version updates
        $this->dispatch(new UpdateLiveCopy());
        $this->dispatch(new UpdateVersionHashes());
        break;

      case 'ping':
      default:
        return response()->json(['result' => Inspiring::quote()]);
    }

    return response()->json();
  }

  public function addVersion(VersionUpdateRequest $request, Filesystem $fs, $key, $hash)
  {
    try
    {
      $path = 'versions/'.$hash.'/';
      $fs->makeDirectory($path, '0755', true, true);
      $fs->cleanDirectory($path);

      foreach ($request->file() as $file)
        $file->move(storage_path('app/'. $path), $file->getClientOriginalName());

      chdir(storage_path('app/'.$path));
      exec('tar -xzf *.tar.gz');

      return response()->json(['hash' => $hash, 'success' => true]);
    } catch (\Exception $e)
    {
      return response()->json(['hash' => $hash, 'success' => false]);
    }
  }
}<commit_msg>More hook feedback.<commit_after><?php namespace App\Http\Controllers;

use App\Jobs\UpdateLiveCopy;
use App\Jobs\UpdateVersionHashes;

use App\Http\Requests\VersionUpdateRequest;

use Illuminate\Filesystem\Filesystem;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Inspiring;
use Illuminate\Http\Request;

class HooksController extends Controller
{
  use DispatchesJobs;

  public function specChange(Request $request)
  {
    switch ($request->header('x-github-event'))
    {
      case 'pull_request':
        // update jobs are only necessary on PR merges
        $json = json_decode($request->input('payload'), true);

        if ($json['action'] == 'closed' && $json['merged'])
        {
          $this->dispatch(new UpdateLiveCopy());
          $this->dispatch(new UpdateVersionHashes());
        }

        return response()->json(['result' => 'Scheduled updates.']);

      case 'push':
        // just initiate spec and version updates
        $this->dispatch(new UpdateLiveCopy());
        $this->dispatch(new UpdateVersionHashes());

        return response()->json(['result' => 'Scheduled updates.']);

      case 'ping':
      default:
        return response()->json(['result' => Inspiring::quote()]);
    }

    return response()->json(['result' => 'Bummer, this call was pointless.']);
  }

  public function addVersion(VersionUpdateRequest $request, Filesystem $fs, $key, $hash)
  {
    try
    {
      $path = 'versions/'.$hash.'/';
      $fs->makeDirectory($path, '0755', true, true);
      $fs->cleanDirectory($path);

      foreach ($request->file() as $file)
        $file->move(storage_path('app/'. $path), $file->getClientOriginalName());

      chdir(storage_path('app/'.$path));
      exec('tar -xzf *.tar.gz');

      return response()->json(['hash' => $hash, 'success' => true]);
    } catch (\Exception $e)
    {
      return response()->json(['hash' => $hash, 'success' => false]);
    }
  }
}
{'fraction_non_alphanumeric': 0.1667558886509636, 'fraction_numerical': 0.0021413276231263384, 'mean_word_length': 3.1476137624861265, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 48, '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': '1069788', 'n_tokens_mistral': 1106, 'n_tokens_neox': 1097, 'n_words': 237}