diff --git a/webapp/controller/BattleController.class.php b/webapp/controller/BattleController.class.php index 94ab3e4c..5b7753b5 100644 --- a/webapp/controller/BattleController.class.php +++ b/webapp/controller/BattleController.class.php @@ -162,17 +162,15 @@ class BattleController extends BaseAuthedController { public function getBattleHistory(){ $mode = getReqVal('mode', 0); - $historyList = BattleHistory::getMyBattleHistory(); + $historyList = BattleHistory::orderBy(BattleHistory::getMyBattleHistoryByMode($mode),'desc'); $data = array(); - foreach ($historyList as $history){ - if ($history['match_mode'] == $mode){ + foreach ($historyList as $k=>$history){ + if ($k < 20){ array_push($data,BattleHistory::toDto($history)); } } - $list = BattleHistory::orderBy($data,'desc'); $this->_rspData(array( - 'data' => $list + 'data' => $data )); } - } diff --git a/webapp/models/BattleHistory.php b/webapp/models/BattleHistory.php index 5e9a50f1..1ed7bcdd 100644 --- a/webapp/models/BattleHistory.php +++ b/webapp/models/BattleHistory.php @@ -21,13 +21,14 @@ class BattleHistory extends BaseModel ); } - public static function getMyBattleHistory() + public static function getMyBattleHistoryByMode($mode) { $row = SqlHelper::ormSelect( myself()->_getSelfMysql(), 't_battle_history', array( 'account_id' => myself()->_getAccountId(), + 'match_mode' => $mode, ) ); return $row;