From 19b7b3186592a9eb82c7f54a07d864c512386793 Mon Sep 17 00:00:00 2001 From: hujiabin Date: Mon, 10 Oct 2022 16:33:22 +0800 Subject: [PATCH] 1 --- webapp/controller/BattleController.class.php | 10 ++++------ webapp/models/BattleHistory.php | 3 ++- 2 files changed, 6 insertions(+), 7 deletions(-) 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;