public function checkForUpdate($gamertag = '') { if ($this->request->ajax() && !\Agent::isRobot()) { try { $account = Account::with('destiny.characters')->where('seo', Text::seoGamertag($gamertag))->firstOrFail(); // We don't care about non-panda members if (!$account->isPandaLove()) { $this->inactiveCounter = 1; } // check for 10 inactive checks if ($account->destiny->inactiveCounter >= $this->inactiveCounter) { return response()->json(['updated' => false, 'frozen' => true, 'last_update' => 'This account hasn\'t had new data in awhile. - <a href="' . URL::action('Destiny\\ProfileController@manualUpdate', [$account->seo]) . '" class="ui horizontal green label no_underline">Update Manually</a>']); } $char = $account->destiny->firstCharacter(); if ($char->updated_at->diffInMinutes() >= $this->refreshRateInMinutes) { // update this $this->dispatch(new UpdateAccount($account)); return response()->json(['updated' => true, 'frozen' => false, 'last_update' => $char->getLastUpdatedRelative()]); } return response()->json(['updated' => false, 'frozen' => false, 'last_update' => $char->getLastUpdatedRelative()]); } catch (ModelNotFoundException $e) { return response()->json(['error' => 'Gamertag not found']); } } }
public function getLightLeaderboard() { $pandas = Account::with('destiny.characters')->whereHas('destiny', function ($query) { $query->where('clanName', 'Panda Love')->where('clanTag', 'WRKD')->where('inactiveCounter', '<', 10); })->get(); $p = []; Hashes::cacheAccountsHashes($pandas); foreach ($pandas as $panda) { $character = $panda->destiny->highestLevelHighestLight(); $p[$character->level][] = ['name' => $panda->gamertag . " (" . $character->class->title . ")", 'maxLight' => $character->highest_light, 'light' => $character->light]; } krsort($p); foreach ($p as $key => $value) { // lets sort the sub levels usort($value, function ($a, $b) { return $b['maxLight'] - $a['maxLight']; }); $p[$key] = $value; } $msg = '<strong>Light Leaderboard</strong><br /><br />'; foreach ($p as $level => $chars) { $msg .= "<strong>Level " . $level . "'s</strong><br />"; $i = 1; foreach ($chars as $char) { $msg .= $i . ". " . $char['name'] . " <strong>" . $char['maxLight'] . "</strong><br />"; $i++; } $msg .= '<br />'; } return Response::json(['error' => false, 'msg' => $msg], 200); }
public function getIndex() { $accounts = Account::with('destiny.characters')->whereHas('destiny', function ($query) { $query->where('clanName', 'Panda Love'); })->orderBy('gamertag', 'ASC')->paginate(15); // attempt hash cache Hashes::cacheAccountsHashes($accounts); return view('destiny.roster', ['members' => $accounts, 'description' => 'PandaLove Destiny Roster page', 'title' => 'PandaLove Destiny Roster']); }
public function getIndex() { $accounts = Account::with('destiny', 'h5.playlists')->whereHas('destiny', function ($query) { $query->where('clanName', 'Panda Love'); })->whereHas('h5', function ($query) { $query->where('totalKills', '!=', 0); })->orderBy('gamertag', 'ASC')->paginate(15); return view('halo5.roster', ['members' => $accounts, 'description' => 'PandaLove Halo 5 Roster page', 'title' => 'PandaLove Halo 5 Roster']); }
public function manualUpdate($seo) { if (\Auth::check()) { try { $account = Account::with('h5.playlists.stock')->where('seo', $seo)->firstOrFail(); $inactive = $account->h5->inactiveCounter; $this->dispatch(new UpdateHalo5Account($account)); // reload account $account = Account::with('h5.playlists.stock')->where('seo', $seo)->firstOrFail(); if ($account->h5->inactiveCounter > $inactive) { // they manually refreshed a profile with no data changes. ugh return redirect('h5/profile/' . $seo)->with('flash_message', ['close' => 'true', 'type' => 'yellow', 'header' => 'Uh oh', 'body' => 'No data changed! Please do not update accounts unless you know they are out of date.']); } else { return redirect('h5/profile/' . $seo); } } catch (ModelNotFoundException $e) { \App::abort(404); } } else { return redirect('h5/profile/' . $seo)->with('flash_message', ['close' => 'true', 'type' => 'yellow', 'header' => 'Uh oh', 'body' => 'You must be signed in to manually update accounts']); } }
/** * Execute the console command. * * @return mixed */ public function handle() { $pandas = Account::with('destiny.characters')->whereHas('destiny', function ($query) { $query->where('clanName', 'Panda Love')->where('inactiveCounter', '<=', 10); })->orderBy('gamertag', 'ASC')->get(); foreach ($pandas as $panda) { $this->info('Processing ' . $panda->gamertag); // check for 10 inactive checks if ($panda->inactiveCounter >= $this->inactiveCounter) { $this->info('This account has not had new data in awhile.'); } $char = $panda->destiny->firstCharacter(); if ($char->updated_at->diffInMinutes() >= $this->refreshRateInMinutes) { // update this try { $this->dispatch(new UpdateAccount($panda)); $this->info('Stats Updated!'); } catch (HashNotLocatedException $e) { $this->error('Could not find hash value: ' . $e->getMessage()); $this->info('Stat update has been skipped.'); } } } }