From 53ea9c77743bda03b3cfad32cc3f7a10be383a29 Mon Sep 17 00:00:00 2001 From: kremsy Date: Thu, 2 Jan 2014 14:31:30 +0100 Subject: [PATCH] statistic insert test fails --- .../core/Statistics/StatisticCollector.php | 12 ++++++++---- application/core/Statistics/StatisticManager.php | 16 ++++++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/application/core/Statistics/StatisticCollector.php b/application/core/Statistics/StatisticCollector.php index f70a7f33..33e32390 100644 --- a/application/core/Statistics/StatisticCollector.php +++ b/application/core/Statistics/StatisticCollector.php @@ -52,8 +52,8 @@ class StatisticCollector implements CallbackListener { //Initialize Settings $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_ON_SHOOT_PRESTORE, 30); + $this->maniaControl->settingManager->initSetting($this, self::SETTING_COLLECT_STATS_MINPLAYERS, 0); + $this->maniaControl->settingManager->initSetting($this, self::SETTING_ON_SHOOT_PRESTORE, 10); } /** @@ -83,15 +83,19 @@ class StatisticCollector implements CallbackListener { $this->onShootArray[$login] = 1; } else { $this->onShootArray[$login]++; + var_dump("test2"); } //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(); $player = $this->maniaControl->playerManager->getPlayer($login); $this->maniaControl->statisticManager->insertStat(self::STAT_ON_SHOOT, $player, $serverLogin, $this->onShootArray[$login]); $this->onShootArray[$login] = 0; } + + // var_dump($this->onShootArray); + var_dump($this->onShootArray[$login]); } @@ -167,7 +171,7 @@ class StatisticCollector implements CallbackListener { break; case 'OnShoot': $paramsObject = json_decode($callback[1][1]); - $this->handleOnShoot($paramsObject->Event->Player->Login); + $this->handleOnShoot($paramsObject->Event->Shooter->Login); break; case 'OnNearMiss': $paramsObject = json_decode($callback[1][1]); diff --git a/application/core/Statistics/StatisticManager.php b/application/core/Statistics/StatisticManager.php index 6c97e305..31b931f6 100644 --- a/application/core/Statistics/StatisticManager.php +++ b/application/core/Statistics/StatisticManager.php @@ -141,8 +141,24 @@ class StatisticManager { $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; + $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 . "` ( `serverLogin`, `playerId`,