1
This commit is contained in:
parent
42fd5e6f56
commit
6b1983dbf3
@ -641,11 +641,14 @@ class UserController extends BaseAuthedController {
|
||||
$mobaData['assist_avg'] = $assistPerMoba;
|
||||
$mobaData['damage_avg'] = $damagePerMoba;
|
||||
$mobaData['recover_avg'] = $recoverHpPerMoba;
|
||||
if (Battle::getBattleCount() >= Battle::VALID_BATTLE_COUNT){
|
||||
|
||||
$totalBattleCount = Battle::getBattleCount();
|
||||
if ($totalBattleCount >= Battle::VALID_BATTLE_COUNT){
|
||||
$userChartData = GlobalData::getUserChartData();
|
||||
if (!$userChartData){
|
||||
$pvpState = isset($userChartData["pvp_state"]) ? $userChartData["pvp_state"] : 0;
|
||||
$mobaState = isset($userChartData["moba_state"]) ? $userChartData["moba_state"] : 0;
|
||||
if (!$userChartData || !$pvpState || !$mobaState){
|
||||
$battlesDb = Battle::getBattleDataLimit();
|
||||
$totalBattleCount = Battle::getBattleCount();
|
||||
$totalAlivePerPvp = 0;
|
||||
$totalKillsPerPvp = 0;
|
||||
$totalAssistPerPvp = 0;
|
||||
@ -657,6 +660,9 @@ class UserController extends BaseAuthedController {
|
||||
$totalDamagePerMoba = 0;
|
||||
$totalRecoverHpPerMoba = 0;
|
||||
$totalLevelPerMoba = 0;
|
||||
|
||||
$totalGameTimesPvp = 0;
|
||||
$totalGameTimesMoba = 0;
|
||||
foreach ($battlesDb as $battle){
|
||||
$battleDataEx = json_decode($battle['battle_data'], true);
|
||||
$pvpDataInfoEx = isset($battleDataEx) ? getXVal($battleDataEx, 'data', array()) : array();
|
||||
@ -671,6 +677,7 @@ class UserController extends BaseAuthedController {
|
||||
$totalDamagePerPvp += $gameTimes_pvp > 0 ? intval($totalDamage_pvp / $gameTimes_pvp) : 0;
|
||||
$totalRecoverHp_pvp = getXVal($pvpDataInfoEx, 'total_recover_hp', 0);
|
||||
$totalRecoverHpPerPvp += $gameTimes_pvp > 0 ? intval($totalRecoverHp_pvp / $gameTimes_pvp) : 0;
|
||||
$totalGameTimesPvp += $gameTimes_pvp;
|
||||
|
||||
$mobaDataInfoEx = isset($battleData) ? getXVal($battleDataEx, 'moba_data', array()) : array();
|
||||
$gameTimes_moba = getXVal($mobaDataInfoEx, 'total_battle_times', 0);
|
||||
@ -684,6 +691,7 @@ class UserController extends BaseAuthedController {
|
||||
$totalDamagePerMoba += $gameTimes_moba > 0 ? intval($totalDamage_moba / $gameTimes_moba) : 0;
|
||||
$totalRecoverHp_moba = getXVal($mobaDataInfoEx, 'total_recover_hp', 0);
|
||||
$totalRecoverHpPerMoba += $gameTimes_moba > 0 ? intval($totalRecoverHp_moba / $gameTimes_moba) : 0;
|
||||
$totalGameTimesMoba += $gameTimes_moba;
|
||||
}
|
||||
$userChartData['pvp_server_data'] = array(
|
||||
"pvp_alive_avg" => intval($totalAlivePerPvp / $totalBattleCount),
|
||||
@ -692,6 +700,7 @@ class UserController extends BaseAuthedController {
|
||||
"pvp_damage_avg" => intval($totalDamagePerPvp / $totalBattleCount),
|
||||
"pvp_recover_avg" => intval($totalRecoverHpPerPvp / $totalBattleCount),
|
||||
);
|
||||
$userChartData["pvp_state"] = $totalGameTimesPvp > Battle::VALID_BATTLE_COUNT ? 1 :0;
|
||||
$userChartData['moba_server_data'] = array(
|
||||
"moba_level_avg" => intval($totalLevelPerMoba / $totalBattleCount),
|
||||
"moba_kills_avg" => intval($totalKillsPerMoba / $totalBattleCount),
|
||||
@ -699,6 +708,7 @@ class UserController extends BaseAuthedController {
|
||||
"moba_damage_avg" => intval($totalDamagePerMoba / $totalBattleCount),
|
||||
"moba_recover_avg" => intval($totalRecoverHpPerMoba / $totalBattleCount),
|
||||
);
|
||||
$userChartData["moba_state"] = $totalGameTimesMoba > Battle::VALID_BATTLE_COUNT ? 1 :0;
|
||||
GlobalData::addUserChartData($userChartData);
|
||||
}
|
||||
$param = 0.95;
|
||||
|
@ -7,8 +7,8 @@ use phpcommon\SqlHelper;
|
||||
|
||||
class Battle extends BaseModel {
|
||||
|
||||
const VALID_GAME_TIMES = 10;
|
||||
const VALID_BATTLE_COUNT = 10000;
|
||||
const VALID_GAME_TIMES = 5;
|
||||
const VALID_BATTLE_COUNT = 100;
|
||||
|
||||
public static function find($accountId){
|
||||
$row = SqlHelper::ormSelectOne(
|
||||
@ -75,7 +75,7 @@ class Battle extends BaseModel {
|
||||
|
||||
public static function getBattleDataLimit(){
|
||||
$limit = self::VALID_BATTLE_COUNT;
|
||||
return myself()->_getSelfMysql()->execQuery("SELECT idx,account_id,battle_data FROM t_battle LIMIT {$limit}");
|
||||
return myself()->_getSelfMysql()->execQuery("SELECT idx,account_id,battle_data FROM t_battle ORDER BY idx DESC LIMIT {$limit}");
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user