<commit_before><?php
namespace Buonzz\Evorg\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;

use Elasticsearch\ClientBuilder;
use Buonzz\Evorg\ClientFactory;

class CreateIndexTemplate implements ShouldQueue
{
    use InteractsWithQueue, Queueable, SerializesModels;

    private $params;

    public function __construct($params)
    {
        $this->params = $params;
    }

    public function handle()
    {
        $params = $this->params['mappings'];

        // get the index name and unset it
        $template_name = $params['index'];
        unset($params['index']);

        // strip off the dates
        $template_name = substr($string, 0, -7);

        $params['name'] = 'evorg-' . md5($template_name);
        $params['body']['template'] = $template_name . "*";

        $client = ClientFactory::getClient();

        try{
                $client->indices()->putTemplate($params);
        }
        catch(\Exception $e){
                \Log::error($e->getMessage());
        }

    }
}<commit_msg>undefined var<commit_after><?php
namespace Buonzz\Evorg\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;

use Elasticsearch\ClientBuilder;
use Buonzz\Evorg\ClientFactory;

class CreateIndexTemplate implements ShouldQueue
{
    use InteractsWithQueue, Queueable, SerializesModels;

    private $params;

    public function __construct($params)
    {
        $this->params = $params;
    }

    public function handle()
    {
        $params = $this->params['mappings'];

        // get the index name and unset it
        $template_name = $params['index'];
        unset($params['index']);

        // strip off the dates
        $template_name = substr($template_name, 0, -7);

        $params['name'] = 'evorg-' . md5($template_name);
        $params['body']['template'] = $template_name . "*";

        $client = ClientFactory::getClient();

        try{
                $client->indices()->putTemplate($params);
        }
        catch(\Exception $e){
                \Log::error($e->getMessage());
        }

    }
}
{'fraction_non_alphanumeric': 0.1363435148295706, 'fraction_numerical': 0.0026560424966799467, 'mean_word_length': 2.7417218543046356, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '500561', 'n_tokens_mistral': 654, 'n_tokens_neox': 652, 'n_words': 131}