<commit_before><?php

namespace App\Console\Commands;

use Carbon\Carbon;
use App\EdiInterface;
use GuzzleHttp\Client;
use Illuminate\Console\Command;
use \Illuminate\Support\Facades\Log;
use \Illuminate\Support\Facades\Storage;
use GuzzleHttp\Exception\RequestException;

class ProcessIncomingEdi extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'edi:incoming';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Processes all incoming EDI files in the bucket';

    /**
     * The HTTP client for reporting
     *
     * @var \GuzzleHttp\Client
     */
    protected $client;

    protected $facetTransaction;

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
        $this->client = new Client([
            'base_uri' => env('APP_URL') . '/api/v1/'
        ]);
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        // List all files on the drive
        $workList = Storage::disk('s3')->allFiles();

        // Loop each file and parse it into a usable object
        foreach ($workList as $ediFile) {
            // Get the transaction data
            $transaction = Storage::disk('s3')->get($ediFile);

            // Parse EDI data into PHP object
            $ediTransaction = $this->parseEdiInterface($transaction);

            // Map the transaction to a Post Award Agreement
            $this->facetTransaction = $this->buildFacetAgreement($transaction);

            // Post the result for real time processing
            $agreementUuid = $this->postAnAward();

            // extract original file data and save to trading partners table
            $path = explode('/', $ediFile);
            $archive = EdiInterface::create([
                'agreement' => $agreementUuid,
                'file_size' => Storage::disk('s3')->size($ediFile),
                'file_name' => $path[sizeof($path) - 1],
                'file_type' => 'x12', // todo identify a more reliable way to derive this than extension
                'file_at' => Carbon::createFromTimestamp(Storage::disk('s3')->lastModified($ediFile), 'America/New_York'),<commit_msg>Fix bug in reference order<commit_after><?php

namespace App\Console\Commands;

use Carbon\Carbon;
use App\EdiInterface;
use GuzzleHttp\Client;
use Illuminate\Console\Command;
use \Illuminate\Support\Facades\Log;
use \Illuminate\Support\Facades\Storage;
use GuzzleHttp\Exception\RequestException;

class ProcessIncomingEdi extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'edi:incoming';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Processes all incoming EDI files in the bucket';

    /**
     * The HTTP client for reporting
     *
     * @var \GuzzleHttp\Client
     */
    protected $client;

    protected $facetTransaction;

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
        $this->client = new Client([
            'base_uri' => env('APP_URL') . '/api/v1/'
        ]);
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        // List all files on the drive
        $workList = Storage::disk('s3')->allFiles();

        // Loop each file and parse it into a usable object
        foreach ($workList as $ediFile) {
            // Get the transaction data
            $transaction = Storage::disk('s3')->get($ediFile);

            // Parse EDI data into PHP object
            $ediTransaction = $this->parseEdiInterface($transaction);

            // Map the transaction to a Post Award Agreement
            $this->facetTransaction = $this->buildFacetAgreement($ediTransaction);

            // Post the result for real time processing
            $agreementUuid = $this->postAnAward();

            // extract original file data and save to trading partners table
            $path = explode('/', $ediFile);
            $archive = EdiInterface::create([
                'agreement' => $agreementUuid,
                'file_size' => Storage::disk('s3')->size($ediFile),
                'file_name' => $path[sizeof($path) - 1],
                'file_type' => 'x12', // todo identify a more reliable way to derive this than extension
                'file_at' => Carbon::createFromTimestamp(Storage::disk('s3')->lastModified($ediFile), 'America/New_York'),
{'fraction_non_alphanumeric': 0.12061769616026712, 'fraction_numerical': 0.00333889816360601, 'mean_word_length': 2.184717607973422, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 33, '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': '6260461', 'n_tokens_mistral': 1322, 'n_tokens_neox': 1279, 'n_words': 363}