<commit_before><?php

namespace Coyote\Console\Commands\Elasticsearch;

use Coyote\Repositories\Contracts\JobRepositoryInterface;
use Coyote\Repositories\Contracts\PostRepositoryInterface;
use Illuminate\Console\Command;

class Index extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'es:index {--model=}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Index data in Elasticsearch.';

    /**
     * @var JobRepositoryInterface
     */
    protected $job;

    /**
     * @var PostRepositoryInterface
     */
    protected $post;

    /**
     * Mapping constructor.
     * @param PostRepositoryInterface $post
     * @param JobRepositoryInterface $job
     */
    public function __construct(PostRepositoryInterface $post, JobRepositoryInterface $job)
    {
        parent::__construct();

        $this->post = $post;
        $this->job = $job;
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        if ($this->confirm('Do you want to index data in Elasticsearch?', true)) {
            $model = ucfirst($this->option('model'));

            if (!$model) {
                $this->indexAll();
            } else {
                if (!method_exists($this, "index{$model}")) {
                    $this->error("$model does not exist");
                }

                $this->{'index' . $model}();
            }

            $this->info('Done.');
        }
    }

    private function indexAll()
    {
        foreach (get_class_methods($this) as $method) {
            if ($method !== 'indexAll' && 'index' === substr($method, 0, 5)) {
                $this->$method();
            }
        }
    }

    private function indexPost()
    {
        $this->line('Indexing posts in Elasticsearch...');
        $this->index($this->post);
        $this->info('Success');<commit_msg>indeksowanie wszystkich elmentow: poprawa buga<commit_after><?php

namespace Coyote\Console\Commands\Elasticsearch;

use Coyote\Repositories\Contracts\JobRepositoryInterface;
use Coyote\Repositories\Contracts\PostRepositoryInterface;
use Illuminate\Console\Command;

class Index extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'es:index {--model=}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Index data in Elasticsearch.';

    /**
     * @var JobRepositoryInterface
     */
    protected $job;

    /**
     * @var PostRepositoryInterface
     */
    protected $post;

    /**
     * Mapping constructor.
     * @param PostRepositoryInterface $post
     * @param JobRepositoryInterface $job
     */
    public function __construct(PostRepositoryInterface $post, JobRepositoryInterface $job)
    {
        parent::__construct();

        $this->post = $post;
        $this->job = $job;
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        if ($this->confirm('Do you want to index data in Elasticsearch?', true)) {
            $model = ucfirst($this->option('model'));

            if (!$model) {
                $this->indexAll();
            } else {
                if (!method_exists($this, "index{$model}")) {
                    $this->error("$model does not exist");
                }

                $this->{'index' . $model}();
            }

            $this->info('Done.');
        }
    }

    private function indexAll()
    {
        foreach (get_class_methods($this) as $method) {
            if ($method !== 'indexAll' && $method !== 'index' && 'index' === substr($method, 0, 5)) {
                $this->$method();
            }
        }
    }

    private function indexPost()
    {
        $this->line('Indexing posts in Elasticsearch...');
        $this->index($this->post);
        $this->info('Success');
{'fraction_non_alphanumeric': 0.14037236648701618, 'fraction_numerical': 0.0009799118079372856, 'mean_word_length': 1.9437635183850035, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, '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': '3621040', 'n_tokens_mistral': 1155, 'n_tokens_neox': 1128, 'n_words': 255}