<commit_before><?php

namespace PandaLove\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Support\Facades\DB;
use Onyx\Halo5\Client;
use Onyx\Halo5\Objects\Playlist;

class updatePlaylists extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'halo5:playlist-update';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Pulls down playlist information into table';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $client = new Client();
        $this->info('Getting new Playlist data from 343');
        $playlists = $client->getPlaylists();

        if (is_array($playlists))
        {
            $this->info('We found Playlist data. Adding to table after purge.');
            foreach($playlists as $playlist)
            {
                try
                {
                    $_playlist = Playlist::where('contentId', $playlist['id'])->firstOrFail();
                    $this->info('Playlist: ' . $playlist['name'] . ' already exists. Updating now.');

                    $_playlist->description = $playlist['description'];
                    $_playlist->isRanked = $playlist['isRanked'];
                    $_playlist->isActive = $playlist['isActive'];
                    $_playlist->save();
                }
                catch (ModelNotFoundException $ex)
                {
                    $this->info('Adding ' . $playlist['name']);
                    $p = new Playlist();
                    $p->name = $playlist['name'];
                    $p->description = $playlist['description'];
                    $p->isRanked = $playlist['isRanked'];
                    $p->isActive = $playlist['isActive'];
                    $p->gameMode = $playlist['gameMode'];
                    $p->contentId = $playlist['id'];
                    $p->imageUrl = $playlist['imageUrl'];
                    $p->save();
                }
            }
        }
    }
}<commit_msg>update playlist name during update for changing playlists<commit_after><?php

namespace PandaLove\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Support\Facades\DB;
use Onyx\Halo5\Client;
use Onyx\Halo5\Objects\Playlist;

class updatePlaylists extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'halo5:playlist-update';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Pulls down playlist information into table';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $client = new Client();
        $this->info('Getting new Playlist data from 343');
        $playlists = $client->getPlaylists();

        if (is_array($playlists))
        {
            $this->info('We found Playlist data. Adding to table after purge.');
            foreach($playlists as $playlist)
            {
                try
                {
                    /** @var $_playlist Playlist */
                    $_playlist = Playlist::where('contentId', $playlist['id'])->firstOrFail();
                    $this->info('Playlist: ' . $playlist['name'] . ' already exists. Updating now.');

                    $_playlist->name = $playlist['name'];
                    $_playlist->description = $playlist['description'];
                    $_playlist->isRanked = $playlist['isRanked'];
                    $_playlist->isActive = $playlist['isActive'];
                    $_playlist->save();
                }
                catch (ModelNotFoundException $ex)
                {
                    $this->info('Adding ' . $playlist['name']);
                    $p = new Playlist();
                    $p->name = $playlist['name'];
                    $p->description = $playlist['description'];
                    $p->isRanked = $playlist['isRanked'];
                    $p->isActive = $playlist['isActive'];
                    $p->gameMode = $playlist['gameMode'];
                    $p->contentId = $playlist['id'];
                    $p->imageUrl = $playlist['imageUrl'];
                    $p->save();
                }
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.13293487221764222, 'fraction_numerical': 0.00247320692497939, 'mean_word_length': 1.6303523035230352, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 40, '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': '5615472', 'n_tokens_mistral': 1331, 'n_tokens_neox': 1273, 'n_words': 270}