<commit_before><?php namespace PandaLove\Http\Controllers\Destiny;

use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Support\Facades\URL;
use Onyx\Account;
use Onyx\Destiny\Helpers\String\Hashes;
use Onyx\Destiny\Helpers\String\Text;
use Onyx\Destiny\Objects\GamePlayer;
use PandaLove\Commands\UpdateAccount;
use PandaLove\Http\Controllers\Controller;
use PandaLove\Http\Requests;

use Illuminate\Http\Request;

class ProfileController extends Controller {

    private $request;

    private $inactiveCounter = 10;
    private $refreshRateInMinutes = 10;

    public function __construct(Request $request)
    {
        parent::__construct();
        $this->request = $request;
    }

    public function index($gamertag = '', $characterId = '')
    {
        try
        {
            $account = Account::with('destiny.characters')
                ->where('seo', Text::seoGamertag($gamertag))
                ->firstOrFail();

            $games = GamePlayer::with('game')
                ->select('game_players.*', 'games.occurredAt')
                ->leftJoin('games', 'game_players.game_id', '=', 'games.instanceId')
                ->where('membershipId', $account->destiny->membershipId)
                ->where('deaths', 0)
                ->orderBy('games.occurredAt', 'DESC')
                ->get();

            $games->each(function($game_player)
            {
                $game_player->url = $game_player->game->buildUrl();
            });

            // setup hash cache
            Hashes::cacheAccountHashes($account, $games);

            return view('destiny.profile', [
                'account' => $account,
                'games' => $games,
                'characterId' => ($account->destiny->characterExists($characterId) ? $characterId : false),
                'description' => ($account->isPandaLove() ? "PandaLove: " : null) . $account->gamertag . " Destiny Profile",
                'title' => $account->gamertag . ($account->isPandaLove() ? " (Panda Love Member)" : null)
            ]);<commit_msg>fix profiles where game was deleted<commit_after><?php namespace PandaLove\Http\Controllers\Destiny;

use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Support\Facades\URL;
use Onyx\Account;
use Onyx\Destiny\Helpers\String\Hashes;
use Onyx\Destiny\Helpers\String\Text;
use Onyx\Destiny\Objects\GamePlayer;
use PandaLove\Commands\UpdateAccount;
use PandaLove\Http\Controllers\Controller;
use PandaLove\Http\Requests;

use Illuminate\Http\Request;

class ProfileController extends Controller {

    private $request;

    private $inactiveCounter = 10;
    private $refreshRateInMinutes = 10;

    public function __construct(Request $request)
    {
        parent::__construct();
        $this->request = $request;
    }

    public function index($gamertag = '', $characterId = '')
    {
        try
        {
            $account = Account::with('destiny.characters')
                ->where('seo', Text::seoGamertag($gamertag))
                ->firstOrFail();

            $games = GamePlayer::with('game')
                ->select('game_players.*', 'games.occurredAt')
                ->leftJoin('games', 'game_players.game_id', '=', 'games.instanceId')
                ->where('membershipId', $account->destiny->membershipId)
                ->where('deaths', 0)
                ->orderBy('games.occurredAt', 'DESC')
                ->get();

            $games->each(function($game_player)
            {
                // Hacky check for when a Game is deleted without deleting GamePlayers
                // @todo write task to remove orphaned GamePlayers & patch Game to delete GamePlayers on delete
                if (isset($game_player->game))
                {
                    $game_player->url = $game_player->game->buildUrl();
                }
            });

            // setup hash cache
            Hashes::cacheAccountHashes($account, $games);

            return view('destiny.profile', [
                'account' => $account,
                'games' => $games,
                'characterId' => ($account->destiny->characterExists($characterId) ? $characterId : false),
                'description' => ($account->isPandaLove() ? "PandaLove: " : null) . $account->gamertag . " Destiny Profile",
                'title' => $account->gamertag . ($account->isPandaLove() ? " (Panda Love Member)" : null)
            ]);
{'fraction_non_alphanumeric': 0.13849977406235878, 'fraction_numerical': 0.0022593764121102574, 'mean_word_length': 2.31114435302917, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 56, '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': '3428440', 'n_tokens_mistral': 1310, 'n_tokens_neox': 1240, 'n_words': 228}