statistic insert test fails

This commit is contained in:
kremsy 2014-01-02 14:31:30 +01:00
parent 9efe8f1ffa
commit 53ea9c7774
2 changed files with 24 additions and 4 deletions

View File

@ -52,8 +52,8 @@ class StatisticCollector implements CallbackListener {
//Initialize Settings //Initialize Settings
$this->maniaControl->settingManager->initSetting($this, self::SETTING_COLLECT_STATS_ENABLED, true); $this->maniaControl->settingManager->initSetting($this, self::SETTING_COLLECT_STATS_ENABLED, true);
$this->maniaControl->settingManager->initSetting($this, self::SETTING_COLLECT_STATS_MINPLAYERS, 4); $this->maniaControl->settingManager->initSetting($this, self::SETTING_COLLECT_STATS_MINPLAYERS, 0);
$this->maniaControl->settingManager->initSetting($this, self::SETTING_ON_SHOOT_PRESTORE, 30); $this->maniaControl->settingManager->initSetting($this, self::SETTING_ON_SHOOT_PRESTORE, 10);
} }
/** /**
@ -83,15 +83,19 @@ class StatisticCollector implements CallbackListener {
$this->onShootArray[$login] = 1; $this->onShootArray[$login] = 1;
} else { } else {
$this->onShootArray[$login]++; $this->onShootArray[$login]++;
var_dump("test2");
} }
//Write Shoot Data into database //Write Shoot Data into database
if($this->onShootArray[$login] > self::SETTING_ON_SHOOT_PRESTORE) { if($this->onShootArray[$login] > $this->maniaControl->settingManager->getSetting($this, self::SETTING_ON_SHOOT_PRESTORE)) {
$serverLogin = $this->maniaControl->server->getLogin(); $serverLogin = $this->maniaControl->server->getLogin();
$player = $this->maniaControl->playerManager->getPlayer($login); $player = $this->maniaControl->playerManager->getPlayer($login);
$this->maniaControl->statisticManager->insertStat(self::STAT_ON_SHOOT, $player, $serverLogin, $this->onShootArray[$login]); $this->maniaControl->statisticManager->insertStat(self::STAT_ON_SHOOT, $player, $serverLogin, $this->onShootArray[$login]);
$this->onShootArray[$login] = 0; $this->onShootArray[$login] = 0;
} }
// var_dump($this->onShootArray);
var_dump($this->onShootArray[$login]);
} }
@ -167,7 +171,7 @@ class StatisticCollector implements CallbackListener {
break; break;
case 'OnShoot': case 'OnShoot':
$paramsObject = json_decode($callback[1][1]); $paramsObject = json_decode($callback[1][1]);
$this->handleOnShoot($paramsObject->Event->Player->Login); $this->handleOnShoot($paramsObject->Event->Shooter->Login);
break; break;
case 'OnNearMiss': case 'OnNearMiss':
$paramsObject = json_decode($callback[1][1]); $paramsObject = json_decode($callback[1][1]);

View File

@ -141,8 +141,24 @@ class StatisticManager {
$serverLogin = $this->maniaControl->server->getLogin(); $serverLogin = $this->maniaControl->server->getLogin();
} }
// $statId = (int)$statId;
// var_dump($statId);
//var_dump($value);
var_dump($serverLogin, $player->index, $statId, $value);
$mysqli = $this->maniaControl->database->mysqli; $mysqli = $this->maniaControl->database->mysqli;
$testquery = "INSERT INTO `" . self::TABLE_STATISTICS . "` (
`serverLogin`,
`playerId`,
`statId`,
`value`
) VALUES (
{$serverLogin}, {$player->index}, {$statId}, {$value}
) ON DUPLICATE KEY UPDATE
`value` = `value` + VALUES(`value`);";
var_dump($testquery);
$query = "INSERT INTO `" . self::TABLE_STATISTICS . "` ( $query = "INSERT INTO `" . self::TABLE_STATISTICS . "` (
`serverLogin`, `serverLogin`,
`playerId`, `playerId`,