added performance on simplestatslist
This commit is contained in:
parent
79f066b473
commit
84eec14b8d
@ -346,12 +346,6 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
* @param array $callback
|
||||
*/
|
||||
public function handleManialinkPageAnswer(array $callback) {
|
||||
$login = $callback[1][1];
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
|
||||
if (!$player) {
|
||||
return;
|
||||
}
|
||||
|
||||
$actionId = $callback[1][2];
|
||||
$enable = (strpos($actionId, self::ACTION_PREFIX_ENABLEPLUGIN) === 0);
|
||||
$disable = (strpos($actionId, self::ACTION_PREFIX_DISABLEPLUGIN) === 0);
|
||||
@ -360,6 +354,12 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
return;
|
||||
}
|
||||
|
||||
$login = $callback[1][1];
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
|
||||
if (!$player) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($enable) {
|
||||
$pluginClass = substr($actionId, strlen(self::ACTION_PREFIX_ENABLEPLUGIN));
|
||||
/** @var Plugin $pluginClass */
|
||||
|
@ -15,6 +15,7 @@ use ManiaControl\Callbacks\CallbackListener;
|
||||
use ManiaControl\Callbacks\CallbackManager;
|
||||
use ManiaControl\Callbacks\Callbacks;
|
||||
use ManiaControl\Commands\CommandListener;
|
||||
use ManiaControl\Logger;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Manialinks\LabelLine;
|
||||
use ManiaControl\Manialinks\ManialinkManager;
|
||||
@ -178,6 +179,7 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
|
||||
// Headline
|
||||
$posX = $xStart + 55;
|
||||
$statRankings = array();
|
||||
|
||||
foreach ($this->statArray as $key => $stat) {
|
||||
$ranking = $this->maniaControl->getStatisticManager()->getStatsRanking($stat["Name"]);
|
||||
if (!empty($ranking)) {
|
||||
@ -208,6 +210,8 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$i = 0;
|
||||
foreach ($statRankings[$order] as $playerId => $value) {
|
||||
if ($index % self::MAX_PLAYERS_PER_PAGE === 1) {
|
||||
$pageFrame = new Frame();
|
||||
@ -237,6 +241,7 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
|
||||
|
||||
$labelLine = new LabelLine($playerFrame);
|
||||
$posX = $xStart + 55;
|
||||
|
||||
foreach ($this->statArray as $stat) {
|
||||
$statValue = 0;
|
||||
if (isset($statRankings[$stat['Name']][$playerId])) {
|
||||
@ -251,10 +256,11 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
|
||||
$label = new Label_Text();
|
||||
$label->setX($posX);
|
||||
$label->setText(strval($statValue));
|
||||
$label->addTooltipLabelFeature($descriptionLabel, '$o ' . $stat['Name']);
|
||||
//$label->addTooltipLabelFeature($descriptionLabel, '$o ' . $stat['Name']);
|
||||
$labelLine->addLabel($label);
|
||||
|
||||
$posX += $stat['Width'];
|
||||
|
||||
}
|
||||
|
||||
$labelLine->addLabelEntryText($index, $xStart + 5, 9);
|
||||
@ -273,6 +279,7 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
|
||||
|
||||
$index++;
|
||||
$posY -= 4;
|
||||
|
||||
}
|
||||
|
||||
$pagerSize = 6.;
|
||||
@ -290,7 +297,6 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
|
||||
|
||||
$paging->addButtonControl($pagerNext)->addButtonControl($pagerPrev)->setLabel($pageCountLabel);
|
||||
|
||||
|
||||
$this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $player, 'SimpleStatsList');
|
||||
}
|
||||
|
||||
|
@ -198,12 +198,13 @@ class StatisticManager implements UsageInformationAble {
|
||||
* @param string $statName
|
||||
* @param $serverIndex
|
||||
* @param $minValue
|
||||
* @param $limit
|
||||
* @internal param $orderedBy
|
||||
* @return array
|
||||
*/
|
||||
public function getStatsRanking($statName = '', $serverIndex = -1, $minValue = -1) {
|
||||
public function getStatsRanking($statName = '', $serverIndex = -1, $minValue = -1, $limit = 500) {
|
||||
if (isset($this->specialStats[$statName])) {
|
||||
return $this->getStatsRankingOfSpecialStat($statName, $serverIndex);
|
||||
return $this->getStatsRankingOfSpecialStat($statName, $serverIndex, $limit);
|
||||
}
|
||||
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
@ -214,7 +215,13 @@ class StatisticManager implements UsageInformationAble {
|
||||
if ($minValue >= 0) {
|
||||
$query .= "AND `value` >= {$minValue} ";
|
||||
}
|
||||
$query .= "ORDER BY `value` DESC;";
|
||||
$query .= "ORDER BY `value` DESC";
|
||||
|
||||
if ($limit > 0) {
|
||||
$query .= " LIMIT 500";
|
||||
}
|
||||
|
||||
$query .= ";";
|
||||
|
||||
$result = $mysqli->query($query);
|
||||
if (!$result) {
|
||||
@ -245,15 +252,16 @@ class StatisticManager implements UsageInformationAble {
|
||||
*
|
||||
* @api
|
||||
* @param string $statName
|
||||
* @param $serverIndex
|
||||
* @param int $serverIndex
|
||||
* @param int $limit
|
||||
* @return array
|
||||
*/
|
||||
public function getStatsRankingOfSpecialStat($statName = '', $serverIndex = -1) {
|
||||
public function getStatsRankingOfSpecialStat($statName = '', $serverIndex = -1, $limit = 500) {
|
||||
$statsArray = array();
|
||||
switch ($statName) {
|
||||
case self::SPECIAL_STAT_KD_RATIO:
|
||||
$kills = $this->getStatsRanking(StatisticCollector::STAT_ON_KILL, $serverIndex);
|
||||
$deaths = $this->getStatsRanking(StatisticCollector::STAT_ON_DEATH, $serverIndex);
|
||||
$kills = $this->getStatsRanking(StatisticCollector::STAT_ON_KILL, $serverIndex, $limit);
|
||||
$deaths = $this->getStatsRanking(StatisticCollector::STAT_ON_DEATH, $serverIndex, $limit);
|
||||
if (!$kills || !$deaths) {
|
||||
return array();
|
||||
}
|
||||
@ -266,8 +274,8 @@ class StatisticManager implements UsageInformationAble {
|
||||
arsort($statsArray);
|
||||
break;
|
||||
case self::SPECIAL_STAT_HITS_PH:
|
||||
$hits = $this->getStatsRanking(StatisticCollector::STAT_ON_HIT, $serverIndex);
|
||||
$times = $this->getStatsRanking(StatisticCollector::STAT_PLAYTIME, $serverIndex);
|
||||
$hits = $this->getStatsRanking(StatisticCollector::STAT_ON_HIT, $serverIndex, $limit);
|
||||
$times = $this->getStatsRanking(StatisticCollector::STAT_PLAYTIME, $serverIndex, $limit);
|
||||
if (!$hits || !$times) {
|
||||
return array();
|
||||
}
|
||||
@ -280,8 +288,8 @@ class StatisticManager implements UsageInformationAble {
|
||||
arsort($statsArray);
|
||||
break;
|
||||
case self::SPECIAL_STAT_ARROW_ACC:
|
||||
$hits = $this->getStatsRanking(StatisticCollector::STAT_ARROW_HIT, $serverIndex);
|
||||
$shots = $this->getStatsRanking(StatisticCollector::STAT_ARROW_SHOT, $serverIndex);
|
||||
$hits = $this->getStatsRanking(StatisticCollector::STAT_ARROW_HIT, $serverIndex, $limit);
|
||||
$shots = $this->getStatsRanking(StatisticCollector::STAT_ARROW_SHOT, $serverIndex, $limit);
|
||||
if (!$hits || !$shots) {
|
||||
return array();
|
||||
}
|
||||
@ -294,8 +302,8 @@ class StatisticManager implements UsageInformationAble {
|
||||
arsort($statsArray);
|
||||
break;
|
||||
case self::SPECIAL_STAT_LASER_ACC:
|
||||
$hits = $this->getStatsRanking(StatisticCollector::STAT_LASER_HIT, $serverIndex);
|
||||
$shots = $this->getStatsRanking(StatisticCollector::STAT_LASER_SHOT, $serverIndex);
|
||||
$hits = $this->getStatsRanking(StatisticCollector::STAT_LASER_HIT, $serverIndex, $limit);
|
||||
$shots = $this->getStatsRanking(StatisticCollector::STAT_LASER_SHOT, $serverIndex, $limit);
|
||||
if (!$hits || !$shots) {
|
||||
return array();
|
||||
}
|
||||
@ -308,8 +316,8 @@ class StatisticManager implements UsageInformationAble {
|
||||
arsort($statsArray);
|
||||
break;
|
||||
case self::SPECIAL_STAT_ROCKET_ACC:
|
||||
$hits = $this->getStatsRanking(StatisticCollector::STAT_ROCKET_HIT, $serverIndex);
|
||||
$shots = $this->getStatsRanking(StatisticCollector::STAT_ROCKET_SHOT, $serverIndex);
|
||||
$hits = $this->getStatsRanking(StatisticCollector::STAT_ROCKET_HIT, $serverIndex, $limit);
|
||||
$shots = $this->getStatsRanking(StatisticCollector::STAT_ROCKET_SHOT, $serverIndex, $limit);
|
||||
if (!$hits || !$shots) {
|
||||
return array();
|
||||
}
|
||||
@ -322,8 +330,8 @@ class StatisticManager implements UsageInformationAble {
|
||||
arsort($statsArray);
|
||||
break;
|
||||
case self::SPECIAL_STAT_NUCLEUS_ACC:
|
||||
$hits = $this->getStatsRanking(StatisticCollector::STAT_NUCLEUS_HIT, $serverIndex);
|
||||
$shots = $this->getStatsRanking(StatisticCollector::STAT_NUCLEUS_SHOT, $serverIndex);
|
||||
$hits = $this->getStatsRanking(StatisticCollector::STAT_NUCLEUS_HIT, $serverIndex, $limit);
|
||||
$shots = $this->getStatsRanking(StatisticCollector::STAT_NUCLEUS_SHOT, $serverIndex, $limit);
|
||||
if (!$hits || !$shots) {
|
||||
return array();
|
||||
}
|
||||
|
@ -1127,7 +1127,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
*/
|
||||
public function handleManialinkPageAnswer(array $callback) {
|
||||
$actionId = $callback[1][2];
|
||||
|
||||
//TODO use manialinkpageanswerlistener
|
||||
$login = $callback[1][1];
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
|
||||
|
||||
|
@ -528,6 +528,7 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList
|
||||
public function handleManialinkPageAnswer(array $callback) {
|
||||
$actionId = $callback[1][2];
|
||||
|
||||
//TODO manialinkpageanswerlsitener
|
||||
$login = $callback[1][1];
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user