Esempio n. 1
0
 public function record_playlist()
 {
     // setup fake PlaylistData with the elements of the best playlist
     // This is bad because we can't leverage pre-loading of data (eager load)
     // so we have n+1 queries here.
     // @todo store highest CSR in a different table to allow eager loading
     $record = new PlaylistData();
     $record->fill($this->highest_playlist());
     if ($record->stock instanceof Playlist) {
         return $record;
     }
     return null;
 }
Esempio n. 2
0
 public function updateArenaServiceRecord($account)
 {
     $record = $this->_getArenaServiceRecord($account);
     $h5_data = $account->h5;
     // dump the stats
     $h5_data->totalKills = $record['ArenaStats']['TotalKills'];
     $h5_data->totalSpartanKills = $record['ArenaStats']['TotalSpartanKills'];
     $h5_data->totalHeadshots = $record['ArenaStats']['TotalHeadshots'];
     $h5_data->totalDeaths = $record['ArenaStats']['TotalDeaths'];
     $h5_data->totalAssists = $record['ArenaStats']['TotalAssists'];
     $h5_data->totalGames = $record['ArenaStats']['TotalGamesCompleted'];
     $h5_data->totalGamesWon = $record['ArenaStats']['TotalGamesWon'];
     $h5_data->totalGamesLost = $record['ArenaStats']['TotalGamesLost'];
     $h5_data->totalGamesTied = $record['ArenaStats']['TotalGamesTied'];
     $h5_data->totalTimePlayed = $record['ArenaStats']['TotalTimePlayed'];
     $h5_data->spartanRank = $record['SpartanRank'];
     $h5_data->Xp = $record['Xp'];
     $h5_data->medals = $record['ArenaStats']['MedalAwards'];
     if ($record['ArenaStats']['HighestCsrAttained'] != null) {
         $h5_data->highest_CsrTier = $record['ArenaStats']['HighestCsrAttained']['Tier'];
         $h5_data->highest_CsrDesignationId = $record['ArenaStats']['HighestCsrAttained']['DesignationId'];
         $h5_data->highest_Csr = $record['ArenaStats']['HighestCsrAttained']['Csr'];
         $h5_data->highest_percentNext = $record['ArenaStats']['HighestCsrAttained']['PercentToNextTier'];
         $h5_data->highest_rank = $record['ArenaStats']['HighestCsrAttained']['Rank'];
         $h5_data->highest_CsrPlaylistId = $record['ArenaStats']['HighestCsrPlaylistId'];
     }
     // clear out old playlist history, dump new playlists
     PlaylistData::where('account_id', $account->id)->delete();
     foreach ($record['ArenaStats']['ArenaPlaylistStats'] as $playlist) {
         $p = new PlaylistData();
         $p->account_id = $account->id;
         $p->playlistId = $playlist['PlaylistId'];
         $p->measurementMatchesLeft = $playlist['MeasurementMatchesLeft'];
         // highest csr
         if ($playlist['HighestCsr'] != null) {
             $p->highest_CsrTier = $playlist['HighestCsr']['Tier'];
             $p->highest_CsrDesignationId = $playlist['HighestCsr']['DesignationId'];
             $p->highest_Csr = $playlist['HighestCsr']['Csr'];
             $p->highest_percentNext = $playlist['HighestCsr']['PercentToNextTier'];
             $p->highest_rank = $playlist['HighestCsr']['Rank'];
         }
         // current csr
         if ($playlist['Csr'] != null) {
             $p->current_CsrTier = $playlist['Csr']['Tier'];
             $p->current_CsrDesignationId = $playlist['Csr']['DesignationId'];
             $p->current_Csr = $playlist['Csr']['Csr'];
             $p->current_percentNext = $playlist['Csr']['PercentToNextTier'];
             $p->current_rank = $playlist['Csr']['Rank'];
         }
         $p->totalKills = $playlist['TotalKills'];
         $p->totalSpartanKills = $playlist['TotalSpartanKills'];
         $p->totalHeadshots = $playlist['TotalHeadshots'];
         $p->totalDeaths = $playlist['TotalDeaths'];
         $p->totalAssists = $playlist['TotalAssists'];
         $p->totalGames = $playlist['TotalGamesCompleted'];
         $p->totalGamesWon = $playlist['TotalGamesWon'];
         $p->totalGamesLost = $playlist['TotalGamesLost'];
         $p->totalGamesTied = $playlist['TotalGamesTied'];
         $p->totalTimePlayed = $playlist['TotalTimePlayed'];
         $p->save();
     }
     $h5_data->save();
 }