Commit 6c1c65d1 authored by saviola's avatar saviola
Browse files

- added limit for collected records before they are stored in the db

- added more debug messages
parent ff9ab8bd
......@@ -78,6 +78,7 @@ class XtsRecord
public $idPlayer = 0;
public $login = null;
public $times = array();
public $timesCount = 0;
public function __construct($login, $idChallenge = null)
{
......@@ -99,6 +100,11 @@ class XtsRecord
return $this;
}
public function getTimesCount()
{
return $timesCount;
}
/**
* Returns current statistics
*/
......@@ -134,6 +140,7 @@ class XtsRecord
public function registerTime($time)
{
$this->times[] = $time/1000;
$this->timesCount++;
$this->checkpoint = null;
}
}
......@@ -300,6 +307,8 @@ function xtsFinished($aseco, $record)
{
if (false === checkStatus($aseco)) return;
XtsLogger::log("Player finished: " . $record->player->login, XtsLogger::DEBUG);
$xts = Xts::getInstance();
$xtsRecord = $xts->getRecord($record->player->login);
......@@ -316,6 +325,12 @@ function xtsFinished($aseco, $record)
}
$xtsRecord->registerTime($record->score);
// save rows for chunks of 50 driven times
if ($xtsRecord->getTimesCount() >= 50)
{
$xts->saveRecords($record->player->login);
}
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment